Orm, that is, object-relationl mapping, is used to map between a relational database and an object. In this way, when we operate a database, you don't need to deal with complex SQL statements, as long as you operate on objects as usual. Below is a reprinted section on the InternetArticleDescription of it:
Let's start with O/R. The letter O originated from "object", while R came from "relational ). Almost allProgramObjects 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 Mapping), you may write a lot of data access layerCodeUsed 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 Mapping. Essentially, an O/R Mapping will generate a dal for you. It is better to use o/R Mapping than to write the Dal code by yourself. You use o/R Mapping to save, delete, and read objects. O/R Mapping is responsible for generating SQL statements. You only need to care about objects.