gpt4 book ai didi

.net - 从 .NET 数据库中检索数据的最快方法?

转载 作者:行者123 更新时间:2023-12-01 07:08:05 25 4
gpt4 key购买 nike

使用 ADO.NET ,从数据库中检索数据并将数据填充到我的业务对象中的最快方法是什么?

我应该使用哪一种? DBDataReader , DBDataAdapter ,或任何其他类?

有没有办法使这个过程自动化?假设基于属性名称并将它们与数据库字段名称匹配?

最佳答案

这听起来就像 ORM 或微 ORM 所做的那样。这是 dapper-dot-net 的输出的 performance tests (大约 1 分钟前运行,在忙于进行一些转码的 PC 上,所以不是 100% 可靠 - 请自己运行)...这也是一个非常有限的测试 - 一如既往,测试应该代表您的特定环境- 但由于我们无法预测您的环境,所以我们使用我们的环境代替!我已将“精巧”的标记为 <==== 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)

关于.net - 从 .NET 数据库中检索数据的最快方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7548921/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com