ORM Framework Design and ORM Framework Design

Source: Internet
Author: User

ORM Framework Design and ORM Framework Design
(I will first copy some ORM information from the Internet.) What is ORM?
ORM (Object-Relational ing) is used to map Relational databases to business-entity objects. ORM is also a standard. A specific ORM framework can serve as a bridge between applications and databases. In this way, we do not need to deal with complex SQL statements when operating on specific business objects. We only need to perform simple operations on the attributes and methods of objects.
Why ORM?
The object-oriented programming language represents the mainstream and trend of the current programming language. It has many advantages, such:
1. object-oriented modeling and operations.
2. polymorphism and inheritance.
3. Abandon the incomprehensible process.
4. Easy to use and easy to understand.
However, the development of databases is not synchronized with programming languages. In addition, some of the advantages of relational database systems cannot be solved by object-oriented languages. For example:
1. Search and sort massive data operations.
2. Set Data Connection operations and mappings.
3. Database Access concurrency and transactions.
4. Database constraints and isolation.
In the face of the coexistence of object-oriented languages and relational database systems, using ORM becomes an inevitable situation. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~ End ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~

 

What is the core purpose of ORM?

Is to let us not care about the database, only care about our objects, set all the Object-Oriented Knowledge Point

How to design an ORM framework by yourself?

There are two parts in total:

First, the ing section (provides XML files that can be configured by the user)

Second, the core part of the Framework (providing APIs for Users)

 

Part 1

The ORM ing part, which is called the ORM. Maps objects to database tables. This part is divided into three parts.

Part 1, Object)

Part 1, database part (relational database RelationShip)

Part 1, Mapping)

How can we collaborate between them?

The Mapping part accesses the Object part and the RelationShip part, and then completes the ing between them.

How to map?

Map the corresponding fields and attributes through the xml file through the Mapping operation.

Part 2

The core part of the framework is that you receive a set or object operation.

What operations should I do after your core class?

Step 1: the Core class parses the XML file according to your ing rules and matches the table corresponding to the object and the column corresponding to the object attribute.

Step 2: The Core class generates corresponding SQL statements based on object operations (add, delete, modify, and query.

Step 3: The Core class accesses the database through ADO. NET and runs SQL statements.

Step 4: return the result. (For query operations, convert the core class to the corresponding object or set and return the result)

According to the existing classes, for example, you now have a User object, and the User object corresponds to a User table, then you find that the add operation is used to build an insert statement in the core class, which table does the insert statement insert? Based on the ing relationship between objects and tables, obtain the Values of which columns of Values? In this case, we can get the attribute from this object. This attribute corresponds to the column and is taken out in sequence. An SQL statement is completed through the core class and such a conversion is completed through the core class. Finally, this SQL statement uses our framework to request a specific database to complete the operation. How to request? Here, we can directly access the database through ADO. NET and finally return the result.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~

Step 1: the Core class parses the XML file according to your ing rules and matches the table corresponding to the object and the column corresponding to the object attribute.

Step 2: The Core class generates corresponding SQL statements based on object operations (add, delete, modify, and query.

Step 3: The Core class accesses the database through ADO. NET and runs SQL statements.

1

 

Step 4: return the result. (For query operations, convert the core class to the corresponding object or set and return the result)

 

 

  

 

Related Article

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.