Since you have chosen LINQ, why don't you try to build the legendary N-layer architecture? Forget it. Let's talk about layer n later. Let's get a three-tier website. Here I will introduce how to use a news system to build a gorgeous three-tier architecture using LINQ to SQL, it involves many things. You can check it out for new and old friends!
(1) first create an ASP. net website is named myweb. Next, create two folders in the project: app_code and presentlayer (presentation layer), and then create two subfolders datalayer and logiclayer in app_code, data Layer and logic layer. After the framework is laid out, such:
(2) Right-click the datalayer folder and choose "Add new item"> "LINQ to SQL" and name it "LINQ. dbml:
Well, this file is similar to dataset. It has its own designer. The designer stores database tables on the left and stored procedures or functions on the right. Leave it alone, and we will proceed with the arrangement.
(3) Right-click logiclayer and choose "Add new item"> "C # class"> "method. cs". Why? Of course, it is about writing business logic. Right-click logiclayer and choose "add existing item". Then, add the dynamic. CS or dynamiclibrary. CS file I mentioned in the previous article. It is a dynamic library of LINQ. Who makes. net.3.5 every integration? Finally, right-click the presentlayer and add default. aspx and a folder section to store the ascx webpage part file:
Well, the three-tier architecture skeleton has been perfectly presented. Does anyone say it's not a four-tier architecture? Hey, this involves the legendary N-layer problem. The N-layer is also split out of the popular three layers. Know the cell division, which is the principle, here we split the presentation layer into a home page layer and a part layer.
(4) The logic layer needs to connect to the data layer, and because it is added to the dynamiclibrary. CS, then method. of course CS needs to reference it, so we have to add the following two sentences: Using datalayer; using system. LINQ. dynamic;
Well, the project structure has been set up. In the next chapter, let's talk about how to set up the data layer.