Orm, that is, object-relationlmapping, maps between relational databases and objects. 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/rmapping), 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. Instead of writing the Dal code, use o/rmapping. 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.