ORM Framework Examples and access testing (10 frameworks)

Source: Internet
Author: User

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

    1. 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)
    2. 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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.