Datarabbit lightweight ORM framework

Source: Internet
Author: User

(The latest version is datarabbit 3.2. Please download it at the end of this article. Last Updated: 2008.11.20)

Datarabbit supports relational-based database operations and ORM-based database operations. It provides built-in support for Oracle and sqlserver and supports other database types through plug-ins. All accessors in datarabbit (all implement the itransactionaccesser Interface) can access the database in the transaction context, or in non-transactions. With datarabbit, you can almost avoid 98% of the SQL statements that need to be handwritten in the program. In this way, your program is safer and easier to modify and maintain.

Before getting to know about datarabbit, you may first read "behind datarabbit (1)-entering the datarabbit context" for better results. This article makes some necessary preparations for understanding datarabbit.

1. accessors in datarabbit
Datarabbit mainly includes the following types of accessors:
(1) ORM accesser (iormaccesser) (and continued)
(2) database-specific relation accesser)
(3) Table-specific relation accesser)
(4) Stored Procedure accesser)
(5) ORM-based object relational loader (ientityrelationloader)
(6) Data outline accesser (idataschemaaccesser)

All accessors shield users from idbcommand, idbconnection, and other objects in the strata. users do not have to worry about complex underlying operations such as opening connections, executing commands, and closing connections. These accessors are inherited from the itransactionaccesser interface. Their class diagrams are as follows:

Datarabbit's ORM is very lightweight and has the following features:
(1) Using emit and generic technology to implement an ORM accesser (iormaccesser) is almost the same as writing SQL.
(2) Using ORM does not require any configuration file (the "Convention" is better than the "configuration" principle is adopted, the entity object and the data table structure are completely consistent, and the tool canEntitycreatorAutomatically Generated)
(3) You can map the master-slave table relationship between databases to the relationship between entity, and load entity based on the master and Foreign keys.
(4) There are no requirements for the structure of database tables. (For example, some ORM frameworks require that data tables have primary keys)

(5) supports efficient "partial update )".

2. Outline operations

Datarabbit supports operations related to the data outline (dataschema), such as extracting the outline of a database table or creating a corresponding database table based on the outline. This can be done through the idataschemaaccesser interface. The class diagrams related to outline operations are as follows:

3. Data Paging
You can use the ipagermanager interface to perform data paging operations (all are implemented using programs without the support of stored procedures ).

4. datarabbit entry --Transactionscopefactory

As the entry point for using the datarabbit framework, a transactionscopefactory instance corresponds to a database.

You can also say that,For a specific database, our application only needs to maintain a transactionscopefactory instance.

Dataconfiguration Config = new dataconfiguration (databasetype. sqlserver, "localhost", "sa", "PWD", "testdb", null );
Transactionscopefactory = new transactionscopefactory ();
Transactionscopefactory. dataconfiguration = config;
Transactionscopefactory. initialize ();

 

With transactionscopefactory, we can get the transactionscope object, and the above various accessors, outline operator, paging manager and other instances can all be obtained through the corresponding method in transactionscope.

For example, to obtain the ORM accesser for the table Student:

Iormaccesser <student> stuormaccesser = transationscope. Newormaccesser<Student> (null );
// Obtain all students older than 20
Ilist <student> stulist = stuormaccesser. getmuch (New Filter (student. _ age, 20, comparisonoperators. Greater ));

For more information about how to better use the datarabbit framework, see the article on best practices for using datarabbit.

 

5. Support for n-layer architecture
How can datarabbit be better integrated into the n-layer architecture? How does one support the BL layer, data layer, and BEM layer?
(1) transactionscope, transaction scope, and various accessors obtained from a transaction return object all work in the same transaction context. Transactionscope instances are generally created in the business flow sublayer.
(2) Integrate datarabbit into the architecture

(3) Best practices for using datarabbit in a three-tier architecture

In subsequent articles, we will introduce the various datarabbit components mentioned above one by one. Below we will provide the latest DLL download of the datarabbit framework and a very simple ORM sample source program, you can try datarabbit's ORM function like this program.

Download resources:
1.Latest VersionDatarabb3.2Download (includingEntitycreator)!Note: From version 3.2, datarabbit is merged into one by three DLL files. V3.2 compatible with v3.1 (last uploaded to 2008.11.20)
2.Datarabbit full manual V1.0

Other articles:
(1) datarabbit 3.0 ORM performance is greatly improved!
(2) Performance Comparison Between datarabbit 3.0 and LINQ to SQL
(3) Batch insert batch inserts!
(4) entity cache (2008.05.28)

From http://www.cnblogs.com/zhuweisky/archive/2007/03/19/680013.html

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.