(Text/steamed bread)
This article describes database operations in detail. The Database Control is modeled after ibatis. an ORM framework developed in the net style, which absorbs several open source code from codeplex and makes improvements based on it. The entire ORM framework is customized and directly encapsulates some commonly used methods of ADO. net. Therefore, the entire structure is clear and easy to expand, develop, and modify.
The access interface class provided by this ORM architecture is datamapper:
1. parameter transfer:
Currently, only two parameter passing formats are available: Generic <t> and hash table hashtable.
2. Data return type:
(1) generic set ilist <t> (Note: The ORM is here)
(2) datatable
(3) Dataset
(4) enumerative ienumerable <t> (Note: This code is inspired by "Lao Zhao"'s blog)
(5) custom memory record set idatareader (Note: This code segment is directly changed from ibatis. Net)
(6) generic Entity classes <t>
(7) object (note: the return value of the executescalar () method)
(8) int (note: the return value of the executenonquery () method)
(9) JSON string (Note: convenient Ajax development and custom Ajax code Links <Custom Ajax controls>)
Among the nine return types above, there are also paging data reads Based on the custom pagemodel. Allows you to develop pages more quickly. In addition, datamapper also adds a transaction mechanism to facilitate database transaction operations.
Some data operation codes are as follows: Hashtable ht = new hashtable ();
Datamapper dm = new datamapper ("user ");
// Generic set
Ilist <sysuser> List = DM. getlist <sysuserinfo> ("selecttop", HT );
// Custom memory record set
Idatareader DR = DM. getdatareader ("selecttop", HT );
Datatable dt = DM. getdatatable ("selecttop", HT );
Datatable dt = DM. getdatatable ("selecttop", HT );
// Output a JSON string, used in combination with Ajax
String jsonstr = DM. getjson ("selecttop", HT );
DM. begintransaction (); // start the transaction
Int I = DM. executeobject ("insert", HT );
DM. Commit (); // submit the transaction
// Others
Parameter fetch (time unit: millisecond): Code
Maximum data records: 1
Getlist: 9
Getdatareader: 0
Getdatatable: 1
Getdataset: 1
Original sqldatareader: 3
Original datatable: 4
Maximum data records: 100
Getlist: 15
Getdatareader: 12
Getdatatable: 10
Getdataset: 8
Original sqldatareader: 5
Original datatable: 11
Maximum data records: 500
Getlist: 22
Getdatareader: 22
Getdatatable: 24
Getdataset: 16
Original sqldatareader: 21
Original datatable: 18
Maximum data records: 1000
Getlist: 33
Getdatareader: 32
Getdatatable: 23
Getdataset: 28
Original sqldatareader: 23
Original datatable: 33
Maximum data records: 5000
Getlist: 130
Getdatareader: 133
Getdatatable: 147
Getdataset: 240
Original sqldatareader: 126
Original datatable: 139
Maximum data records: 10000
Getlist: 257
Getdatareader: 318
Getdatatable: 284
Getdataset: 579
Original sqldatareader: 243
Original datatable: 280
Click here to return:Quick Development Framework Based on ORM