Summary of ASP. net mvc three-layer architecture knowledge

Source: Internet
Author: User

After using MVC for team development, I realized the convenience of object-oriented software development. When using MVC, the low coupling between layers makes the relationship between them very much, which reduces the degree of dependency between modules.

First, we will introduce the significance of MVC and the usage and functions between different layers.

1) entity layer. It is mainly used to declare the carrier for transferring data between the view layer and the business logic layer. It usually represents a meaningful record composed of one or more tables in the source and project database.

2) business logic layer. Provides data to the view layer according to the business logic. The class in this project has the right to decide whether to call the database access layer method based on the business logic.

3) database access layer. The business logic layer provides methods to access data.

4) view layer. This article mainly uses website development as an example. Displays, adds, edits, and deletes data.

The structure of the project I created in:

 

 

 

NetMVC is the so-called view layer. Entity is an Entity layer used to declare all variables to be used during development. DAL is the database access layer, mainly used to access the database through all operations. BLL is the business logic layer. It processes the business logic sent from the view layer and then passes it to the database access layer for processing.

This example mainly demonstrates the implementation of the login page. The Entity Layer Code is as follows:
 

Using System; using System. collections. generic; using System. text; namespace Entity {public class UserInfo {private int UserId; /// <summary> /// user ID // </summary> public int UserId1 {get {return UserId;} set {UserId = value ;}} private string username; // <summary> // Logon account name // </summary> public string Username {get {return username ;} set {username = value ;}} private string password; // <summary> // logon Password /// </summary> public string password {get {return password ;} set {password = value ;}} private int loginCount; // <summary> // Number of logins /// </summary> public int LoginCount {get {return loginCount ;} set {loginCount = value ;}} private DateTime regDate; // <summary> // registration time /// </summary> public DateTime RegDate {get {return regDate ;} set {regDate = value ;}} private DateTime lastLoginDate; /// <summary> /// last logon time /// </summary> public DateTime LastLoginDate {get {return lastLoginDate;} set {lastLoginDate = value ;}} private bool isForbidden; private string passwordQuestion; // <summary> // a password retrieval error is prompted. /// </summary> public string PasswordQuestion {get {return passwordQuestion ;} set {passwordQuestion = value ;}} private string passwordAnswer; /// <summary >/// retrieve the password /// </summary> public string PasswordAnswer {get {return passwordAnswer ;}set {passwordAnswer = value ;}}}}


 

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.