EF-查看生成的SQL语句

时间:2014-01-14 21:34:08   收藏:0   阅读:855

老版本中:EF 4和EF 3.5 SP1

bubuko.com,布布扣
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();
    }
}
View Code

EF4.1及其以上:

bubuko.com,布布扣
            LckDbContext ef = new LckDbContext();
            var personInfo = from a in ef.Persons.Include("Photo")
                             select a;         
            Console.WriteLine(personInfo.ToString());
View Code

 

注:

 

http://www.cnblogs.com/LingzhiSun/archive/2011/05/05/EF_Trick5.html

原文:http://www.cnblogs.com/i-blog/p/3513442.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!