OR mapping research report

xiaoxiao2021-03-06  42

Or Mapping Research Report 1. Design of business entity layer Selection 1) The role of the business entity layer The structure of the application layers is as follows:

It can be seen that when we are layered, we will add an entity layer, its role is as follows: a. Separate the display data and the actual storage area to ensure the independence of the business, improve reusability. B. Transfer data between the business layer and the performance layer. (If there is no physical layer, we need to pass each field of the table as a parameter, if modified, will need to affect the various layers of the program) C. Provide greater receptiveness. 2) Several options and advantages of business entity layers. In the .NET environment, the business entity has the following options: a. DataReader BE has the fastest read speed, used for read-only, does not have an OO concept. B. XML BE can be converted to XML Reader and DataSet. Disadvantages: low performance, verification, resolution, display, and sorting, etc. are complex. C. Generic DataSet Be Advantages: Data Binding, etc. Disadvantages: The client must obtain data through a collection, no type, instantiated cost, low scheduling performance. D. Typed DataSet Be Advantages: Type checks can be performed by the type. Disadvantages: Can only inherit from DataSet, deployment is inconvenient, scalable, large-scale overhead, low scheduling performance. E. Custom Be Advantages: Performance Tuning, Code is more readable, defined a good interface with custom entity classes, and hide complex problems. Disadvantages: Design development is very complicated, you need to implement the CURD operation, you can achieve data binding, the workload is large. F. Or mapping implementation It has all the advantages of the custom class, and implements the operation of CRUD, data binding. 2. What is or mapping? ORM, ie Object-relationl mapping, its role is to make a mapping between the relational database and objects, so that we don't need to go and complicate SQL when we do a specific operational database. The statement depends, as long as it operates like a usual operation object. Let us start from OR. The letter O originated from "object" (Object), and R comes from "relational". Almost all programs, there are objects and relational databases. In the business logic layer and the user interface layer, we are object-oriented. When the object information changes, we need to save the information of the object in the relational database. When you develop an application (not using or mapping), you may write a lot of data access layers, used to save, delete, read object information, and so on. You have written a lot of methods in DAL to read object data, change status objects, and the like. These codes are always repeated. If you open your nearest program, look at DAL code, you will definitely see a lot of approximately general mode. In order to save objects, we pass an object, add SQLParameter for the SQLCommand object, corresponding to all attributes and objects, set SQLCommand's CommandText attribute as a stored procedure, and then run SQLCommand. Write these code for each object. In addition, is there a better way? Yes, introduce an or mapping. In essence, an or mapping will generate DAL for you. It is better to use or mapping with your own written DAL code.

You use or maping, delete, read objects, or mapping is responsible for generating SQL, you only need to care about the object. 3. Why do I use or mapping? 1) improve learning development efficiency and reduce development costs. Using ORM can greatly reduce learning and development costs, the development of modern technology, making us have to keep learning. We must not only learn knowledge-oriented, UML, design patterns, etc., but also need to learn SQL Server, ADO.NET, DATASET, DATAREADER and other knowledge. In actual development, it is its unique business function for customers. The current status is that we spend a lot of time in writing data access, Crud method, including the later BUG lookup, maintenance, etc. It is quite a number of times on the data processing. That is to say, we have been wasted at all non-business incidents that do not create value in actual development. After using ORM, we will not need to waste too much time on the ADO.NET and SQL statements. The ORM framework has turned a database into our familiar objects, we will only need to understand the development of database applications for object-oriented development. 2) Simplify the code and reduce the number of bugs. By establishing an ORM system, it is possible to reduce the program development code. After the ORM is realized, the development of the data layer is relatively simple, and it greatly reduces the chance of error. 3) Improve performance At the same time through Cache, it is possible to tune performance, and the ORM is realized between the actual data storage and the business layer, which can be subjected to separate tracking of each layer, and increase performance optimization. 4) Isolation data source, it can be easily converted to the data store with ORM, which does not need to be actually stored, if we need to change the SQL Server database to an Oracle database, just modify configuration If the file can be, no modification is required. 2) Simplify the code and reduce the number of bugs. By establishing an ORM system, it is possible to reduce the program development code. After the ORM is realized, the development of the data layer is relatively simple, and it greatly reduces the chance of error. 3) Improve performance At the same time through Cache, it is possible to tune performance, and the ORM is realized between the actual data storage and the business layer, which can be subjected to separate tracking of each layer, and increase performance optimization. 4) Isolation data source, it can be easily converted to the data store with ORM, which does not need to be actually stored, if we need to change the SQL Server database to an Oracle database, just modify configuration If the file can be, no modification is required. 4. ORM Typical Tools Introduction Due to the power brought by ORM, there have been many companies or individuals to provide ORM tools. There are three main ways: a. Microsoft provided ObjectSpaces Microsoft provides ObjectSpaces in the Alpha version of VS.NET 2005, which is a layer ORM framework on the ADO.NET data layer. However, according to the message provided on the Microsoft website, ObjectSpaces will not be released with the VS.Net 2005, which may be released together in 2006 (7) and WinFS. So you may not be able to use in the nearest project. B. Free ORM of open source is still far less than the Java field, but many people have transferred the best development source code in the Java field to the .NET platform.

转载请注明原文地址:https://www.9cbs.com/read-68697.html

New Post(0)