开发者

Fastest way to retrieve data from a database in .NET?

开发者 https://www.devze.com 2023-04-08 20:40 出处:网络
Using ADO.NET, what is the fastest way to retrieve data from the database and populate the开发者_JAVA百科 data into my business objects?

Using ADO.NET, what is the fastest way to retrieve data from the database and populate the开发者_JAVA百科 data into my business objects?

Which one should I use? DBDataReader , DBDataAdapter, or any other classes?

Is there a way to make this process automated? Let's say based on property names and matching them with database field names?


That sounds exactly like what an ORM or micro-ORM does. Here's the output of dapper-dot-net's performance tests (run about 1 minute ago, on a PC that is also busy doing some transcoding, so not 100% reliable - please run yourself)... This is also a very limited test - as always, tests should be representative of your specific environment - but since we can't predict your environment, we use our environment instead! I've marked the "dapper" ones as <==== dapper

Running 500 iterations that load up a post entity
Mapper Query (non-buffered) took 57ms          <==== dapper
hand coded took 57ms
Dynamic Mapper Query (buffered) took 58ms      <==== dapper
PetaPoco (Fast) took 58ms
Dynamic Mapper Query (non-buffered) took 59ms  <==== dapper
Mapper Query (buffered) took 60ms              <==== dapper
Dapper.Cotrib took 60ms                        <==== dapper
PetaPoco (Normal) took 66ms
Dynamic Massive ORM Query took 67ms
BLToolkit took 88ms
Simple.Data took 96ms
Linq 2 SQL Compiled took 99ms
NHibernate Session.Get took 127ms
SubSonic Coding Horror took 128ms
Entity framework CompiledQuery took 130ms
NHibernate HQL took 132ms
NHibernate SQL took 134ms
NHibernate Criteria took 173ms
Soma took 184ms
Linq 2 SQL ExecuteQuery took 230ms
Linq 2 SQL took 694ms
NHibernate LINQ took 700ms
Entity framework ESQL took 730ms
Entity framework ExecuteStoreQuery took 735ms
Entity framework took 991ms
Entity framework No Tracking took 1011ms
SubSonic ActiveRecord.SingleOrDefault took 4345ms
(end of tests; press any key)


If you want automated you are looking for an orm. You might check out some of the lighter wieght ones like massive, ormlite, dapper, and PetaPoco.


Using ADO.NET, what is the fastest way to retrieve data from the database and populate the data into my business objects?

Is there a way to make this process automated? Let's say based on property names and matching them with database field names?

Dapper. Absolutely blazing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号