What kind of ORM framework do we need following the last ORM?
10 examples of ORM framework tests have been sorted out in no particular order
- Crl
- Ef
- Pdf
- XCODE
- NHibernate
- Mysoft
- Moon
- Cyq
- Dapper
- Ibatisnet
In the above frame, the style is different, most of the semi-object, need to be in the form of parameters, efficiency may be high, but programming and convenience will almost
Objective
- Test ORM Data Access performance, relatively simple brute, statistical object mapping conversion and return time, (pure-object ORM takes longer than an ORM in the form of parameters)
- ORM Development Call implementation, different ORM development style and ease of glance
Test results
- EF and NHibernate average down a little bit slower, other differences are small
- An ORM that implements a purely object-only operation can be more convenient.
To demonstrate the ORM process, use objects as much as possible to represent
Entity interface
Public interface iproduct { int Id {get; set;} String ProductId {get; set;} String ProductName {get; set;} String BarCode {get; set;} DateTime addtime {get; set;} }
Test interface
Public interface Itester { iproduct getproduct (int index); String Remark {get;} BOOL Insert (int index); int Select (int index); int Update (int index); int Delete (int index); }
Interface implementation examples
public class Crltester:itester {public string Remark {get {Retu RN ""; }} public iproduct getproduct (int index) {return new Product () {Id = index, ProductName = "ProductName" + index, BarCode = "BarCode" + index, addtime = DateTime.Now}; } public bool Insert (int index) {var data = getproduct (index) as Product; PRODUCTMANAGE.INSTANCE.ADD (data); return true; } public int Select (int index) {var data = getproduct (index) as Product; var list = ProductManage.Instance.QueryList (b = = B.productname = = data. ProductName); Return list. Count; } public int Delete (int index) {var data = getproduct (index) as Product; var n = ProductManage.Instance.Delete (b = = b.ID = = data. ID); return n; } public int Update (int index) {var data = getproduct (index) as Product; Because it is not queried, manually set which properties have been changed by data. Change (b = b.productname); Data. Change (b = b.barcode); return ProductManage.Instance.Update (data); } }
test Procedure , call the interface implementation, to delete and change the loop to execute the specified number of times
static string Dotest (Itester tester, Testtype type,int N) {STOPW atch SW = new Stopwatch (); Insert SW. Start (); for (int i = 1, i <= N; i++) {switch (type) {case Testtyp E.delete:tester. Delete (i); Break Case TestType.INSERT:tester. Insert (i); Break Case TestType.SELECT:tester. Select (i); Break Case TestType.UPDATE:tester. Update (i); Break }} SW. Stop (); var times = SW. Elapsedmilliseconds; var avg = times/convert.todouble (n); return string. Format ("{0}, spents {1} milliseconds average {2}", type, SW. Elapsedmilliseconds, avg); }
operation, no local database, no reference to data
Project: Http://files.cnblogs.com/files/hubro/ORMTest.rar
Please change the data connection in config file, ibatisnet need to modify it separately
ORM Framework Examples and access testing (10 frameworks)