EF-查看生成的SQL语句
2024-09-30 18:49:32
老版本中:EF 4和EF 3.5 SP1
using (var context = new TestDBEntities())
{
var query = from p in context.Parents
where p.Name == "Lingzhi"
select p; ObjectQuery<Parent> parents = query as ObjectQuery<Parent>;
if (parents != null)
{
string sql = parents.ToTraceString();
}
}
EF4.1及其以上:
LckDbContext ef = new LckDbContext();
var personInfo = from a in ef.Persons.Include("Photo")
select a;
Console.WriteLine(personInfo.ToString());
注:
- 以上方法在Linq语法时支持友好,但在Lamda函数式查询时不是很好。
- 其他方式,SqlServer中可以用SQL Server Profiler监控等
http://www.cnblogs.com/LingzhiSun/archive/2011/05/05/EF_Trick5.html
最新文章
- 窥探Swift之别具一格的Struct和Class
- Effective C++ -----条款08: 别让异常逃离析构函数
- Linux环境下使用C/C++编写CGI(httpd)
- Local Optimization Revisited
- 通过Foxit和坚果云实现iPad和PC的pdf同步阅读(修改,笔记)
- android lsitview setOnItemLongClickListener 无效或不执行
- 如何用ZBrush雕刻出栩栩如生的头发(二)
- codeforces 713C C. Sonya and Problem Wihtout a Legend(dp)
- 知识点摸清 - - position属性值之relative与absolute
- Alamofire网络库进阶教程
- html5之datalist标签
- Shell curl 和 wget 使用代理IP
- Android Studio设置代理更新下载SDK
- 偶现bug如何处理?
- Ignite(一): 概述
- vue初体验
- YUM仓库服务与PXE网络装机
- 全排列(dfs)
- BEGIN-4_蓝桥杯_Fibonacci数列
- java.lang.Object类
热门文章
- 解决Windows+Eclipse+Python错误: SyntaxError: Non-ASCII character
- 使用GitHub For Windows托管Visual Studio项目
- Linux中的堡垒--iptables
- 测试php页面执行代码时间
- 使用Fiddler提高前端工作效率 (实例篇)
- Windows(Vertrigo)下Apache与Tomcat的整合
- yum使用详细
- Linux Makefile analysis for plain usr
- css实现红十字会图标
- BZOJ 1827: [Usaco2010 Mar]gather 奶牛大集会