Petshop4.0 Design Description
I. Project Name and description: (implementation steps: 4-3-6-5-2-1)
1. Web = Presentation Layer
2. BLL = business logic layer
3. idal = data access layer interface definition
4. Model = Business Entity
5. dalfactory = Abstract Factory of the data layer (create reflection)
6. sqlserverdal = sqlserver data access layer/oracledal = ORACLE data access layer
Dbutility database access component basic class
2. Project Reference relationship
1. The web references BLL.
2. BLL references idal and model and uses dalfactory to create an instance.
3. The idal references the model.
4. The model is not referenced.
5. dalfactory references idal and readsProgramSet to load the class instance and return it to BLL for use.
6. sqlserverdal references model and idal, and is loaded by dalfactory to implement the methods in the interface.
3. Implementation steps
1. Create a model to implement business entities.
2. Create an idal to implement the interface.
3. Create sqlserverdal to implement the methods in the interface.
4. Add the configuration information in Web. config as the sqlserverdal assembly.
5. Create dalfactory and return the instance of the specified class of the Assembly.
6. Create BLL and call dalfactory to obtain the instance of the specified class of the assembly and complete the data operation method.
7. Create a web and call the data operation method in BLL.
(3) implementation steps
1. Create an empty solution, add an empty folder (you can name it at will), and then add various class library projects and websites in this solution.
2. Create a class library project (model) and set the Assembly name, default namespace, and assembly signature.
3. Design classes in the model class library (implement serialization, [serializable]). Because the model component mainly contains data entity objects, class members mainly include private fields, attributes, and constructors.
4. Modify the assemblyinfo. CS file to record the assembly information.
5. Create a class library project (idal) and set the Assembly name, default namespace, and assembly signature.
6. Add a reference to the petshop. model. dll assembly.
7. design the interface in the idal class library.
8. Modify the assemblyinfo. CS file to record the assembly information.
9. Repeat steps 5-8 to create a sqlserverdal class library project and implement the methods in the idal interface.
TIPS: it is best to add info to the class name in the model class library, for example, categoryinfo. CS.
When naming classes in the idal class library, it is best to add I in front, for example: icategory. CS
When naming classes in the sqlserverdal class library, nothing can be added, such as category. CS.
In this way, when these class names appear in the sqlserverdal class library, you do not need to add a namespace limit before the class name to distinguish them.
10. Create a web project, reference the sqlserverdal assembly, and. add a key-value pair to the configuration section of the appsettings In the config file. <add key = "webdal" value = "petshop. sqlserverdal "/>
11. To create a dalfactory class library project, you only need to create a dataaccess class, create a Private Static read-only field, and store the reference path ("webdal") of the sqlserverdal Assembly obtained through the Web. config file "). Create a static constructor of the dataaccess class. Create a public static method and return the instance of the specified class of the Assembly.
12. Create a BLL class library project, design related business logic classes, call the dalfactory static method, obtain the instance of the specified class of the Assembly, and complete the data operation method.
13. In a web project, design the presentation layer and call the data operation method in BLL to obtain data.
Note:
1. The Assembly name in Web. config must be consistent with the output Assembly name in sqlserverdal.
2. Only one dataaccess class is required in dalfactory to create all Assembly instances.
3. After the project is created, modify the default namespace and Assembly name for each project.
4. Pay attention to modifying project dependencies in the solution.
5. Add project references in the solution.