IQueryable query = from x in appEntities where x.id = 10 select x; var sql = ((System.Data.Objects.ObjectQuery)query).ToTraceString();
或者 EF6 :sql
var sql = ((System.Data.Entity.Core.Objects.ObjectQuery)query) .ToTraceString();