Three-layer structure in ASP. NET development mode

Source: Internet
Author: User

ASP. NET has been available for several years, but the traditional Form mode is still used in the development mode, without the support of mature development modes. The disadvantage of this technology is obvious. The Code has low reusability and poor scalability, which makes it difficult to modify and maintain it in the future.

For the purpose of development, I have designed an ASP. NET development mode. Let's talk about it and discuss it. If the design is poor, please kindly advise.

An example of the three-tier architecture of ASP. NET development mode is as follows:

 
 
  1. using System;  
  2. using System.Text;  
  3. using System.Data;   
  4. namespace AccessHelper  
  5.    {      
  6.     public interface IHelper      
  7.          {          
  8.              DataTable ExecuteReader(string connectionString, CommandType cmdType, string cmdText);  
  9.              int ExecuteNoneQuery(string connectionString, CommandType cmdType, string cmdText);          
  10.              object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText);          
  11.              void AddParameter(string key, object value);    }  
  12.  
  13.     } 

The IHelper interface of DbHelper module is defined as follows::

IHelper is used to directly execute SQL statements. Its three main methods are divided based on the three methods of the Command object. The ExecuteReader method returns the DataTable type, and uses DataAdapter to Fill the data to the DataTable. The advantage of doing so is to disconnect the database as soon as possible and release resources.

The DbDAO module is defined based on a specific Model class. Its function is to convert the DataTable from DbHelper to a specific class. DbDAO uses the DataBaseType parameter to instantiate the corresponding IHelper class using the DBHelperFactory factory class.

The DbDAL module is used to process various data access logics, such as logon and registration.

This is a simple ASP. NET design mode. Using a three-tier structure on the basis of this mode can facilitate project development and code maintenance.

  1. Use AJAX in ASP. NET
  2. Compatibility between the WCF Service and ASMX service in ASP. NET
  3. Explore new ASP. NET technologies for more convenient Web development
  4. Using usage in ASP. NET
  5. Analysis of health monitoring in ASP. NET project development

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.