Three-tier architecture website (1)

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.