如何从Linq to Entities得到生成的T-SQL语句

 1 class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5             BreakAwayEntities context = new BreakAwayEntities();
 6             var query = from r in context.Reservations join p in context.Payments on r.ReservationID equals p.ReservationID select new { r.Customer, p.Reservation };
 7             string sql = ((ObjectQuery)query).ToTraceString();
 8             Console.WriteLine(sql);
 9             Console.Read();
10         }
11     }

 

posted @ 2012-05-18 10:54  Allen Li  阅读(3485)  评论(2编辑  收藏  举报