Traditional Culture Encyclopedia - Traditional virtues - C# three-tier structure design details

C# three-tier structure design details

This you more than a few times to play the code, more than a few cases, you understand, it's very simple. Three layers include: business logic layer, data access layer, representation layer, there is generally a model layer, I give you a project to do the idea of it. If you do three layers, start building a good three layers, that is, MODEL (model layer), DAL (data access layer), BLL (business logic layer), and a website or form (representation layer). Then follow the steps to 1. Add external references to the three layers of the correspondence between the reference, and then add the internal reference, generally DAL references MODEL, BLL references DAL and MODEL, the representation layer references BLL and MODEL. 2. Write the model layer, if the database is not very complex, you see how many tables in the database you want to use, write the model layer in the Corresponding to the table name of the same class, and then some of the corresponding table fields in the class encapsulated attributes. 3. Write the data access layer, which writes your specific database operation methods, corresponding to the fields to be inserted through the creation of MODEL layer class instances to call the MODEL layer class corresponding to encapsulated attribute fields. 4. Write the business logic layer, that is, to summarize the methods of the DAL encapsulation, let the Representation layer to use, so that the representation layer to save the DAL to call specific methods. 5. write the representation layer, call the corresponding method in the BLL is OK. I hope this helps you!