公司项目数据库访问采用的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]

最新文章

  1. HTTP 源码解读
  2. cs端调用Ajax
  3. Hadoop及其相关组件简介
  4. UVa 107 - The Cat in the Hat (找规律,注意精度)
  5. AndroidStudio 问题汇总
  6. GZIP 头解析
  7. Proxy 模式
  8. Clementine 12.0 的使用安装(数据挖掘)
  9. Mybatis 示例之 复杂(complex)属性(property)
  10. if __name__ == &#39;__main__&#39;在python中的应用
  11. 官方问答--微信小程序常见FAQ (17.8.21-17.8.27)
  12. June 14. 2018 Week 24th Thursday
  13. 20165223 week1测试查漏补缺
  14. Visual Basic 2017 操作Excel和word【1】持续更新……
  15. tomcat jetty
  16. CH 2601 - 电路维修 - [双端队列BFS]
  17. 虚幻4:2D游戏中实现二级或多级跳跃
  18. leetcode题库解答源码(python3)
  19. Java - ArrayList源码分析
  20. pandas read_csv 读取中文列标题文件报错

热门文章

  1. RabbitMQ入门教程——.NET客户端使用
  2. Oracle12c安装出错
  3. mysql错误一例:ERROR 1030 (HY000): Got error 28 from storage engine
  4. SQL Server锁定【2015.12.17】
  5. 《PHP开发APP接口》笔记
  6. 1---------java调用NLPIR(ICTCLAS2016)实现分词功能
  7. Java文件选择对话框(文件选择器JFileChooser)的使用:以一个文件加密器为例
  8. 创建基于Bootstrap的下拉菜单的DropDownList的JQuery插件
  9. UVA 11582 Colossal Fibonacci Numbers!【数学】
  10. using关键字的使用