What is O/R Mapping (ORM)?

Source: Internet
Author: User

ORM, or Object-relationl Mapping, is a mapping between relational databases and objects, so that when we operate the database, we don't have to deal with complex SQL statements, as long as we manipulate them as usual. The following is a description of it in an article reproduced online:
Let's start with the O/R. The letter O originates from the object and R is from the relationship (relational). In almost all programs, objects and relational databases exist. In the business logic layer and the user interface layer, we are object-oriented. When the object information changes, we need to keep the object's information in the relational database.
When you develop an application (without the O/R Mapping), you may write a number of data access layer code that can be used to save, delete, read object information from the database, and so on. You write a lot of methods in the Dal to read the object data, change the state object, and so on. And the code is always repetitive.
If you open your recent program and look at the DAL code, you'll definitely see a lot of approximate generic patterns. We take the method of saving the object as an example, you pass in an object, add SqlParameter to the SqlCommand object, match all the properties and objects, set the CommandText property of the SqlCommand as the stored procedure, and then run SqlCommand. This code is written repeatedly for each object.
Besides, there is a better way. There, introduce an O/R Mapping. Essentially, an O/R mapping will generate a DAL for you. Instead of writing the DAL code yourself, use the O/R Mapping. You use O/R mapping to save, delete, read objects, O/R mapping responsible for generating SQL, you only need to care about the object.

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.