将Linq转换为SQL的便捷方法

以下代码可以将Linq快捷的转换为SQL,以供我们分析程序。,以下是代码:
   1:  using (NorthwindEntities context = new NorthwindEntities())
   2:  {
   3:      string s = string.Empty;
   4:   
   5:      var query = context.Region.Where(o=>o.RegionID<100).OrderBy(p=>p.RegionID);
   6:      s = (query as ObjectQuery).ToTraceString();
   7:      Response.Write(s);
   8:   
   9:      Response.Write("<hr/>");
  10:   
  11:      var query1 = from p in context.Region
  12:                   where p.RegionID > 0
  13:                   select p;
  14:      s = (query1 as ObjectQuery).ToTraceString();
  15:      Response.Write(s);
  16:  }

你可能感兴趣的:(将Linq转换为SQL的便捷方法)