老版本中: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

最新文章

  1. 窥探Swift之别具一格的Struct和Class
  2. Effective C++ -----条款08: 别让异常逃离析构函数
  3. Linux环境下使用C/C++编写CGI(httpd)
  4. Local Optimization Revisited
  5. 通过Foxit和坚果云实现iPad和PC的pdf同步阅读(修改,笔记)
  6. android lsitview setOnItemLongClickListener 无效或不执行
  7. 如何用ZBrush雕刻出栩栩如生的头发(二)
  8. codeforces 713C C. Sonya and Problem Wihtout a Legend(dp)
  9. 知识点摸清 - - position属性值之relative与absolute
  10. Alamofire网络库进阶教程
  11. html5之datalist标签
  12. Shell curl 和 wget 使用代理IP
  13. Android Studio设置代理更新下载SDK
  14. 偶现bug如何处理?
  15. Ignite(一): 概述
  16. vue初体验
  17. YUM仓库服务与PXE网络装机
  18. 全排列(dfs)
  19. BEGIN-4_蓝桥杯_Fibonacci数列
  20. java.lang.Object类

热门文章

  1. 解决Windows+Eclipse+Python错误: SyntaxError: Non-ASCII character
  2. 使用GitHub For Windows托管Visual Studio项目
  3. Linux中的堡垒--iptables
  4. 测试php页面执行代码时间
  5. 使用Fiddler提高前端工作效率 (实例篇)
  6. Windows(Vertrigo)下Apache与Tomcat的整合
  7. yum使用详细
  8. Linux Makefile analysis for plain usr
  9. css实现红十字会图标
  10. BZOJ 1827: [Usaco2010 Mar]gather 奶牛大集会