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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - 五味果

.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]