From ORM to talk about data persistence and orm

Source: Internet
Author: User

From ORM to talk about data persistence and orm

 

What is ORM?

ORM (ObjectRelational Mapping) object-relational ing is generated with the development of object-oriented software. ORM is a program technology used to convert data of different types of systems in object-oriented programming languages. In terms of effect, it is actually a virtual object database that can be used in programming languages, that is, relational databases will appear as objects in programming languages.

 

Why use ORM?

1: objects and relational databases exist in almost all object-oriented programs. In the business logic layer and user interface layer, We are object-oriented, but when the object information changes, we need to save the object information in the relational database. In this way, programmers not only need to study business logic and UI code, but also focus on SQL and other database operation statements. The emergence of ORM frees programmers from SQL to a certain extent and focuses on business logic, so as to improve development efficiency.

2: From the O-R, in addition to the convenience of operations in 1, why do we want to convert the relational database to Object, DataSet is not good?

We know that objects can be inherited and interfaces can also be used. It can be said that after Ralation is converted to an Object, not only the form changes, but the key is that the original Ralation has the object-oriented feature.

For example, I can check whether the object supports the IVersionObject interface in the program. If yes, we will automatically implement version control. If you give me a DataSet, then I will not be able to detect (do not tell me whether the Version field exists ). With this feature, we can automate many things.
For another example, I designed a base class for the document entity, including the SheetCode, SheetDate, and other fields. Then, my OrderSheet inherits from SheetBase and they will automatically get these standard fields, in addition, my basic classes can automatically help me deal with many unified rules to make the program more stable and unified. This Relation is very difficult to achieve.

 

Data Persistence

I recently learned about Microsoft's EF (EntityFramwork). As An ORM (Object Relational Mapping) framework. net, there is a very interesting word in the EF learning process-"data persistence", which makes me not understand. It is said that EF achieves data persistence, so in the end

What is data persistence?

Data Persistence is a general term used to convert a data model in memory into a storage model and a data model in memory. the data model can be any data structure or object model, and the storage model can be a relational model, XML, binary stream, etc. --- Baidu encyclopedia

In a narrow sense, persistence only refers to permanent storage of object data in the database. In a broad sense, persistence includes database-related operations.

In my personal understanding, the persistence in the narrow sense of data persistence is relative to the concept of "temporary". Generally, data is stored in two storage locations on the computer, and the memory is saved for storage. The database can be understood as permanent. In this way, in the development process, ADO. NET accesses the database, that is, data persistence. Further, all database-related operations can be considered as data persistence? (If you are confused, I hope you will have different understandings and have more discussions)

In the broad sense, persistence is a technology like EF that encapsulates data access details and provides object-oriented APIs for most business logic.

Why persistence (in a broad sense )?

The persistence technology encapsulates data access details and provides object-oriented APIs for most business logic.

● The Persistence technology can reduce the number of accesses to database data and increase the application execution speed;

● High code reusability, able to complete most database operations;

● Loose coupling makes persistence independent of the underlying database and upper-layer business logic. When changing a database, you only need to modify the configuration file instead of the Code.

 

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.