Reputation: 203
Is there a way I can view the Entity Sql (eSQL) that my Linq-to-entities queries are generating with EF framework (that is, not native SQL, but eSQL, if that makes sense?)
Thanks!
Upvotes: 6
Views: 1364
Reputation: 99
To view linq query in development environment.
view example in image https://i.sstatic.net/t6PK6.png
Upvotes: 0
Reputation: 867
var query1 = from person in Database
select person.Name;
You can cast the query1 into ObjectQuery and use the ToTraceString method to see the query.
Console.WriteLine(((ObjectQuery)query1).ToTraceString());
Upvotes: 1
Reputation: 122032
You can't. It is not generated.
Actually, LINQ to Entities queries are translated directly into Expression Tree, and the nodes of this Expression Tree are translated into SQL clauses, and then integrated into a SQL query. No Entity SQL.
Upvotes: 8