Datarabbit enterprise-level data access framework (21) -- datarabbit 4.0 & datarabbit integrates with three-tier architecture demo source code

Source: Internet
Author: User

Compared with the previous version, datarabbit 4.0 has the following major enhancements:

1. provides five entity caches. Entitycacheserver is directly provided to publish the synchronous cache service in remoting mode. The following blog will detail the use of entitycacheserver.

Public   Enum Cachetype
{
///   <Summary>
/// During static initialization, the qualified entity objects are loaded into the cache. Since then, these objects have been resident in the memory.
///   </Summary>
Static =   0 ,

//


// Hot is used to cache active entity objects and regularly Delete inactive entity objects.
//
Hot,

//


// timingrefresh: the cache that is regularly refreshed. You can regularly load the latest qualified entity from the dB to replace the old entity in the memory.
//
timingrefresh,

//


// ndayincreasing is used to cache incremental caching of Entity objects in the last n days. In addition, the entity object of the oldest day will be removed from the cache.
//
ndayincreasing,

//


// synchronization is the entity cache that is fully synchronized with the database. All modifications to the tentity table must be performed through syncentitycache.
//
synchronization,

/// <Summary>
///Virtualsync provides the same access interface as the synchronized object cache for data tables that do not need to be cached.
/// </Summary>
Virtualsync
}

For more information about the primary version of synchronous object cache, see here.

 

2. The datarabbit ORM has a greater enhancement, including

(1) supports queries such as Max, Min, sum, AVG, and count:

///   <Summary>
/// Getsinglevalue: queries a single value, such as Count, Max, and sum.
///   </Summary>
T getsinglevalue < T > ( Singlevaluequerytype Querytype, String Columnname, Params   Filter [] Conditions );
T getsinglevalue < T > ( Singlevaluequerytype Querytype, String Columnname, Ifiltertree Tree );

The generic parameter t indicates the type of the single value to be queried. Singlevaluequerytype is an enumeration type, indicating the single-value query to be performed:

[ Enumdescription ( " Single-value Query type " )]
Public   Enum   Singlevaluequerytype
{
[ Enumdescription ( " Count " )]
Count =   0 ,
[ Enumdescription ( " Max " )]
Max,
[ Enumdescription ( " Min " )]
Min,
[ Enumdescription ( " Sum " )]
Sum,
[ Enumdescription ( " AVG " )]
AVG
}

 

(2) Support for distinct queries

///   <Summary>
/// Getdistinctlist queries the list of all values in a column.
///   </Summary>
Ilist < T > Getdistinctlist < T > ( String Columnname, Params   Filter [] Conditions );
Ilist < T > Getdistinctlist < T > ( String Columnname, Ifiltertree Tree );

 

(3) ORM Built-in high-performance paging Query

Tentity [] getpage ( Int Pagesize, Int Pageindex, String Columnorderby, Bool Ascend, Ifiltertree Tree );
Tentity [] getpage ( Int Pagesize, Int Pageindex, String Columnorderby, Bool Ascend, Params   Filter [] Conditions );
Datatable Getpage ( Int Pagesize, Int Pageindex, String Columnorderby, Bool Ascend, Ifiltertree Tree, Params   String [] Columns );

For paging query, you can return the datatable of the corresponding page or the corresponding entity array.

To make any query efficient, you must create an appropriate index when designing the database. This is essential. Otherwise, the best built-in paging policy of datarabbit will not help.

 

Since the release of datarabbit 1.0, we have been in 4.0 today. The biggest difference is that there is no good demo as a reference. Today, I will personally make up for this regret.

Drtest is a demo using datarabbit. The main purpose of this demo is:

(1) how to use the common ORM functions of datarabbit.

(2) how to combine datarbbit with a three-tier architecture. For more information about L3 architecture, see my blog: http://www.cnblogs.com/zhuweisky/archive/2009/05/13/1456011.html

About the drtest solution:

(1) drtest. entity is the definition of entity class and the definition of basic or enumeration types used in each layer.

(2) The name of drtest. BEM is "Business Entity Management". It really deals with databases. The usage of datarbbit's ORM function can be seen from its source code.

(3) drtest. blinterface is the interface definition of the business logic layer. If BL and UI are not deployed on the same machine, the UI Layer only needs to reference drtest. blinterface, instead of referencing drtest. BL.

(4) In the drtest. Bl business logic layer, all business logic processing is performed here.

(5) The drtest. UI is used to display data, submit queries, and perform other interface operations.

(6) Please note that this demo does not take into account the handling of many exceptions and exceptions, which cannot be ignored in real projects.

 

Click here to download datarabbit4.0 _ demo. After decompression, the files in the resources directory are explained as follows:

(1) entitycreator supports the Entity Generator of datarabbit 4.0.

(2) The testdb. SQL file is used to generate a script for testing the database testdb. (I use sqlserver2008. For MySQL 2000 and MySQL 2005, datarabbit is also supported)

(3) datarabbit. dll and datarabbit. dbaccessing. dll are datarabbit 4.0ProgramSet, which depends on my basic library esbasic. dll.

(4) datarabbit full album .doc, based on datarabbit 4.0.

 

Leave a message if you have any suggestions, or e-mail your sky.zhuwei@163.com

Zhuweisky 2009.07.12

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.