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

2024-11-20 12:30:39
推荐回答(1个)
回答1:

如何从Linq to Entities得到生成的T-SQL语句
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 }