Evaluate the performance of LINQ to SQL (list some of the program execution programs)

Source: Internet
Author: User

 

Starting at one time, I optimized the performance of LINQ to SQL,

In order to balance the cost of 100000 million RMB, the total value of 5 times is special.

Retrieve Method Result
With un-typed datatable load (use dataadapter without delete/insert/update Assocation) 5188 MS
With LINQ to SQL 4203 MS

I was very impressed with the performance of writing to SQL, And it was faster than the un-typed datatable. However, in theory,

The cost of the products produced by LINQ to SQL should be lower than that produced by datarow, but such a gap can cause my doubts,

Maybe I still have some mistakes. When I have time, I can refer to the fill mechanism of the linq to SQL statement and find it.

Performance Improvement Certificate.

 

Lists some of the zookeeper programs.

With untyped datatable

Static void testuntypedload ()
{
Sqlconnection conn = new sqlconnection (dsperformancetest. properties. settings. Default. northwind2connectionstring );
Datatable table = new datatable ();
Using (conn)
{
Using (sqlcommand cmd = new sqlcommand ("select * From test_table", Conn ))
{
Using (sqldataadapter adapter = new sqldataadapter (CMD ))
{
Adapter. Fill (table );
}
}
}
}

 

With LINQ to SQL

Static void testloadwithlinq ()
{
Northwinddatacontext context = new northwinddatacontext ();
VaR S = (From S1 in context. test_tables select S1). tolist ();
}

 

 

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.