Nhibernate + WCF + asp.net MVC + nvelocity PetShop4.0 Refactoring (iii)--persistence layer
What is a persistence layer? First, explain what is persistent, English persistence, solidify the data in memory and keep it in the physical storage device. However, in enterprise application, it is often through relational database to complete this process. The persistence layer is defined as a separate domain dedicated to persisting data relative to the presentation layer and business layer in the three-tier architecture. The "single responsibility" principle in the design pattern defines the purpose of layering, and the persistence layer is specifically dealing with the database. As shown in Figure 1
Figure 1
The DAL (Database access layer) in PetShop4.0 is the operation database. In its DAL, returns DataReader through an SQL statement, assigns a value to the model object, generates an SQL statement from the model object's data in the Add, modify, delete operation, and writes to the database. At this point, we can see that each table is doing the same thing. Although PetShop4.0 uses SqlHelper to encapsulate database operations, it does not have a common crud package. Currently PetShop4.0 each table corresponds to a variety of crud, so there will be a lot of duplicate code.
For PetShop4.0 use of multiple clock database to speak. A DAL is written for each of the databases. So the database portability is not strong.