Object relational mapping (ORM for short). I believe everyone should be familiar with it. It is a technology designed to solve the mismatch between object-oriented and relational databases. Using the O/R Mapping mode to develop database applications can save a lot of work, especially the compilation of cumbersome SQL statements. Of course, using the O/R Mapping technology also has its disadvantages, is things always imperfect!
The o/R Mapping technology implemented by the dohope. Net generator also generates code at the business layer and data layer based on actual project factors, saving a lot of time for development and management information systems.
Note that the database table must have a primary key.
Version V 1.0 (SQL version) is now released. You are welcome to provide bugs during use.Download the dohope. Net Generator
Code Generator interface:
The following is a test project with a three-tier architecture. The bll and Dal layers are automatically generated for the code.
The following are some simple examples:
Configure global. asax. CS (database connection and type) as follows:
Protected void application_start (Object sender, eventargs E)
{
String connectionstring = system. configuration. configurationsettings. appsettings ["sqlconnectionstring"]. tostring ();
TS. Dal. database. connectionstring = connectionstring;
TS. Dal. database. databasetype = ts. Dal. databasetype. sqlserver;
}
Example of adding a record:
City Ct = New City ();
Cityrow Cr = CT. createrow ();
Cr. ID = city. getnextid ("");
Cr. cityid = This. textbox6.text. Trim ();
Cr. City = This. textbox5.text. Trim ();
Cr. Father = This. textbox4.text. Trim ();
Ct. Save ();
Example of modifying a record:
City Ct = New City (convert. todecimal (this. Key. Text ));
CT [0, 0]. cityid = This. textbox1.text. Trim ();
CT [0, 0]. City = This. textbox2.text. Trim ();
CT [0, 0]. Father = This. textbox3.text. Trim ();
Ct. Save ();
Example of deleting a record:
City Ct = New City (convert. todecimal (this. Key. Text ));
Cityrow Cr = CT [convert. todecimal (this. Key. Text)];
Ct. Delete (CR );
Query read data:
City Ct = New City (convert. todecimal (I ));
This. textbox1.text = CT [0, 0]. cityid;
This. textbox2.text = CT [0, 0]. City;
This. textbox3.text = CT [0, 0]. Father;
This. Key. Text = CT [0, 0]. Id. tostring ();