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 ();
}