惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
D
Docker
N
Netflix TechBlog - Medium
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
IT之家
IT之家
月光博客
月光博客
U
Unit 42
K
Kaspersky official blog
T
Threatpost
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
GbyAI
GbyAI
P
Proofpoint News Feed
Last Week in AI
Last Week in AI
云风的 BLOG
云风的 BLOG
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
Engineering at Meta
Engineering at Meta
Recorded Future
Recorded Future
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
大猫的无限游戏
大猫的无限游戏
Security Archives - TechRepublic
Security Archives - TechRepublic
Webroot Blog
Webroot Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
S
Schneier on Security
S
Secure Thoughts
The Register - Security
The Register - Security
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
P
Palo Alto Networks Blog
爱范儿
爱范儿
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 热门话题
C
Cisco Blogs
Spread Privacy
Spread Privacy
F
Full Disclosure
博客园 - 聂微东
T
The Blog of Author Tim Ferriss

博客园 - 五味果

.net Core 调用微信Jsapi接口,H5解析二维码 TextBoxFor控件的扩展---Bootstrap在mvc上的应用 外地手机号码,请在号码前加拨0 Sql 2012 远程数据库连接 DbEntry在Vs2012里的配置 终点,也是新的起点! 天气预报数据查询接口 关于浏览器账号的一个愿望 关于移动,联通,电信的区分。 - 五味果 - 博客园 被#号折腾了。 Orm 请别让数据库中的默认值形同虚设!! 利用反射,泛型,静态方法快速获取表单值到Model。 subsonic sqlite 路径问题 - 五味果 ORM是工具,工具是用来提高开发速度的。 基于XML的后台管理系统--设想 项模板的使用--提高编程速度 C#开发编码规范 基于Jquery的内容显示模块 - 五味果 - 博客园 IIS7下运行Access+Asp的解决方法
Dapper Vs Dbentry
五味果 · 2015-02-11 · via 博客园 - 五味果

公司项目数据库访问采用的dapper,以前没有用过。今天简单的测试下了,dapper和dbentry 查询效率情况。

  public ActionResult Test()
        {
            Sys_UserFacade su = new Sys_UserFacade();      
           var result = string.Empty;
           System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
           sw.Start();
           var list = su.GetSys_UserList();
           sw.Stop();
           result += "Dapper:查询" + list.Count() + "条数据耗时" + sw.ElapsedMilliseconds + "毫秒 ";
           sw.Reset();
           sw.Start();
           var list2 = SysUser.Find(u=>u.LoginCount==2);
          
           sw.Stop();
           result += "Vs Dbentry:" + list2.Count() + "条数据耗时" + sw.ElapsedMilliseconds + "毫秒<hr/>";         
           return Content(result);
        }

sql 2012 ,本机,140W+数据,进行了简单的全表查询,和条件查询。执行效率如下:

Dapper:查询1408128条数据耗时7474毫秒 Vs Dbentry:1408064条数据耗时6370毫秒
Dapper:查询1408128条数据耗时7372毫秒 Vs Dbentry:1408064条数据耗时6453毫秒
Dapper:查询1408128条数据耗时7423毫秒 Vs Dbentry:1408064条数据耗时6466毫秒
Dapper:查询1408128条数据耗时7288毫秒 Vs Dbentry:1408064条数据耗时6646毫秒
Dapper:查询1408128条数据耗时7172毫秒 Vs Dbentry:1408064条数据耗时6667毫秒
Dapper:查询128条数据耗时50毫秒 Vs Dbentry:128条数据耗时30毫秒
Dapper:查询128条数据耗时47毫秒 Vs Dbentry:128条数据耗时29毫秒
Dapper:查询128条数据耗时42毫秒 Vs Dbentry:128条数据耗时30毫秒
Dapper:查询128条数据耗时41毫秒 Vs Dbentry:128条数据耗时38毫秒
Dapper:查询128条数据耗时44毫秒 Vs Dbentry:128条数据耗时29毫秒

总结:两个效率差不多,dbentry 略胜一点。

今天使用dapper时候遇到一个小问题,数据库连接字符串在web.config配置如下

<connectionStrings>
<add name="SmDbConnectionString" connectionString="Data Source=(local);Initial Catalog=***;User ID=xxx;Password=xxxx" providerName="System.Data.SqlClient" />
</connectionStrings>

在程序中采用

 cnnStringName = ConfigurationManager.ConnectionStrings[0].Name;  

访问连接字符串名,发现返回的连接名并不是想要的。而是继承了Machine.config中的连接。

解决办法:

1:在web.config connectionStrings节点中先添加个 <clear/>

2:或者直接ConfigurationManager.ConnectionStrings[1]