ASP. NET It has been around for several years, but the traditional development model is still used. Form Mode, not mature MVC architecture support. The disadvantage of this mode is obvious. Code has low reusability and poor scalability, which makes it difficult to modify and maintain code in the future.
for development purposes, I designed a MVC
MVC the mode structure is as follows:
Code
Using System;
Using System. text;
Using System. Data;
Namespace Accesshelper
{
Public Interface Ihelper
{
Datatable executereader ( String Connectionstring, commandtype connector type, String Plain text );
Int Executenonequery ( String Connectionstring, commandtype connector type, String Plain text );
Object Executescalar ( String Connectionstring, commandtype connector type, String Plain text );
Void Addparameter ( String Key, Object Value );
}
}
dbhelper module ihelper the interface is defined as follows:
Ihelper For direct execution SQL Statement. The three main methods are based on Command Objects are divided by three methods. Where Executereader The method returns Datatable Type, use Dataadapter Data Fill To Datatable . The advantage of doing so is to disconnect the database as soon as possible and release resources.
Dbdao The module depends on the specific Model Class. Its function is Dbhelper Come on Datatable Convert to a specific class. Dbdao PASS Parameters Databasetype Parameter, use Dbhelperfactory The factory class instantiates the corresponding Ihelper Class.
dbdal the module is used to process various data access logics, such as logon and registration.