What is o/R mapper?

Source: Internet
Author: User

Summary after reading:
O/R Mapping is the relational object ing.
Databases are used to map classes and data tables.
The advantage is that it can automatically generate an object to save, delete, and read SQL statements.
Currently, ado.net objectspaces does not support Chinese queries. The version only supports SQL Server 2000 or later;
Looking forward to ADO. net2.0

Original article:
What is o/R mapper?

Author: Huo www.aspcool.com time: 13:35:56 views: 2352
 

Abstract In http://www.aspcool.com/lanmu/browse1.asp? Id = 1115 & bbsuser = CSHARP

What is o/R mapper?

One chat with a friend in a group. Some people say that they have recently discovered a new database design method, which is to map database columns and object attributes one by one. This design is very convenient. I said cold, it's so easy. The actual situation is complicated. How can we make a one-to-one correspondence.

Then, dude, I don't understand it. Article As an argument, I'll open it and look at it. It's about o/R mapper. I can't do anything cold. I don't dare to say much.

There is always a lack of good Chinese articles on o/R Mapper, which makes many people confused. What is o/R mapper?

Steve eichert's series of articles spoke well. I plan to follow the translation and add some knowledge to myself. Of course, I also hope to help more people.

Original article: http://dotnetjunkies.com/weblog/seichert/posts/4677.aspx

What is o/R mapper?



Recent Community We will discuss more and more O/R Mapper, but what is o/R mapper?
Let's start with O/R. The letter O originated from "object", while R came from "relational ). Almost all Program Objects and relational databases exist. In the business logic layer and user interface layer, We are object-oriented. When the object information changes, we need to save the object information in the relational database.

When you develop an application (do not use o/R Mapper), you may write a lot of data access layer Code Used to save, delete, and read object information from the database. You have written many methods in the Dal to read object data, change State objects, and so on. These codes are always repeated.
If you open your recent program and look at the Dal code, you will certainly see many similar general patterns. Let's take the method of saving objects as an example. You pass in an object, add sqlparameter to the sqlcommand object, map all attributes to the object, set the commandtext attribute of sqlcommand as the stored procedure, and then run sqlcommand. This code must be repeatedly written for each object.
In addition, is there a better way? Yes. Introduce an O/R mapper. Essentially, an O/R mapper will generate a dal for you. It is better to use o/R mapper than to write the Dal code by yourself. You use o/R Mapper to save, delete, read objects, and O/rmapper to generate SQL statements. You only need to care about objects.

Okay. What's the problem? Haha, I have never discussed this part of mpaaer. We know that we have objects and relational databases. We have our own o/R mapper between them. In many cases, the attribute of an object cannot be 100% consistent with that of a database column. To save the firstname attribute of our customer object to the first_name column in The t_customer table of the database, we need to do some "mapping ". We need o/R Mapper to save the firstname attribute to the first_name column in The t_customer table. We set these mappings in O/R mapper. In addition to mapping object attributes, we also need to define keys and object relationships.

Excellent o/R mappers will provide a designer to help us set all the mapping needed. Some immature (mostly free) objects and database mappings are defined using XML files, while others are completed using custom attributes. The mapping method is not the most important. It is important that the O/R mapper allows us to set mappings.

After all mapping is defined, this o/R mapper can help us do a lot of work. Through these mappings, this o/R mapper can generate all SQL statements about saving, deleting, and reading objects. We no longer need to write so many lines of Dal code.
O/R mappers is much more than what I have discussed. In future posts, I will continue to discuss other functions provided by O/R mappers.

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.