For learning, I chose the Access database + stored procedures, here is recorded my personal learning experience and notes, and the Internet may be different, the view can not be all the same.
Why use a three-tier structure:
The first thing to be clear is that the three-tier structure does not make the system faster, and in fact it is slower than a "single class" structure. But more and more people use the three-tier structure to develop, why? I am in use, found that three-layer structure is very clear, a class, a file you should put on which layer on which layer, will not be like a single type of structure all put into the app_data, resulting in structural chaos. Of course, the reason for using the three-tier structure is certainly not so superficial, it is very important for team development and system maintainability.
Three-tier structure is the increase in code, and the code more repeat?
Sure, three-tier code to write a lot of stupid, very simple code, such as model of the entity class, if you need an admin entity, then you need to write this code:
Copy Code code as follows:
public class Admin
{
private int? _id;
private string _sname;
private string _spassword;
public int? Id
{
set {_id = value;}
get {return _id;}
}
public string sname
{
set {_sname = value;}
get {return _sname;}
}
public string Spassword
{
set {_spassword = value;}
get {return _spassword;}
}
}
And there are multiple entities, you have to write these stupid code, why call it an idiot code? Because of the code, you can write it by looking at a table. One and soup discussion, introduced a software, called "Dynamic soft." NET code generator ", these idiot code lets this software own to build!" Here also recommended that you use this software, you can reduce a lot of code, Bll,dal,web layer of code can be generated, but to fully comply with the use of words, but also need to make some changes.
Here are three layers that I understand, first on Figure 1:
Web: interface layer, in fact, is a Web site.
BLL: Logical processing layer.
DAL: Data Access Layer
Dbutility: Data-tier base class
Model: Entity classes
Common: Storing common functions
Figure 2
Here's the dbutility layer, you can see there are 4 files:
1, DbHelperOleDb.cs: for SQL statements
2, DbHelperOleDbP.cs: for Stored procedures
3, DbHelperOleDbS.cs: For specific implementation, such as "based on the conditions to determine whether there", "return the largest ID" ...
4, PubConstant.cs: Database Connection code
Current 1/4 page
1234 Next read the full text