Three-tier architecture, three-tier architecture and mvc difference

Source: Internet
Author: User

Three-tier architecture, three-tier architecture and mvc difference

The three-layer architecture includes the presentation layer (UI) and business logic layer(BLL (Business Logic Layer ))Data Access Layer (DAL) and Object Library (Model)

1. The object library (Model) Stores Table fields in the database.

Operation:

(1) first, create an object class library Model, open the project, right-click solution> Add> Create Project> select class library> rename Model> OK

(2) Select the Model class library --> Shift + ALT + C --> Create an object class. UserInfo class

namespace Model{   public  class UserInfo    {        public string  UserName { get; set; }        public string  Password { get; set; }    }}

2. Data access layer (DAL) is mainly used to store access to data classes, that is, basic operations such as adding, deleting, modifying, and updating databases.

 

Operation:

 

(1) first, create the data access layer class library DAL, open the project, right-click the solution, and choose add> new project> select class library> rename DAL> OK.

(2) Add a reference to the Model in the DAL, and select DAL -- Alt + P + R -- Solution -- project -- select MOdel -- and OK.

(3) Add a reference to system. configuration in DAL, and select DAL --> Alt + P + R --> assembly --> framework --> select System. configuration --> OK.

(4) create a data category and select DAL --> Shift + ALT + C --> Create a data category. UserDB class

Namespace DAL {class UserDB {private string connString = ConfigurationManager. connectionStrings [connString]. toString (); public int AddUser (UserInfo userInfo) {// Add a user operation to the database string commandText = insert into UserInfo (userName, Password) values (@ userName, @ Password); SqlParameter [] paras = new SqlParameter [] {new SqlParameter (@ userName, userInfo. userName), new SqlParameter (@ Password, userInfo. password)}; return SqlHelper. executeNonQuery (connString, CommandType. text, commandText, paras );}}

 

3. the business logic layer (BLL) performs logical judgment and discount on transmitted data and transfers the correct value.

 

 

(1) first create the business logic layer class library BLL, open the project, right-click the solution, and choose add> new project> select class library> rename BLL> OK.

(2) Add a reference to Model and DAL to BLL, and select BLL --> Alt + P + R --> solution --> project --> select MOdel and DAL --> OK.

(3) create a business logic class, and select BLL --> Shift + ALT + C --> create a business logic class. LoginManager class

 

4.The presentation layer (UI) is the user interface layer.

 

(1) Add a reference to Model and BLL in the UI. Select UI -- Alt + P + R -- Solution -- project -- and select MOdel and BLL --.

(2) write code to pass data to the BLL layer.

 

 

 

Related Article

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.