LINQ query to SQL Script
Is anyone heard of any tool writing LINQ queries and converting them to SQL queries?
I mostly ne开发者_StackOverflow社区ed this because I am a .NET developer and I'm weak in this section of SQL queries where sometimes I need them.
Thank you.
Have you tried using LINQPad? That lets you see the SQL generated when it runs the query - and of course it's easy to experiment with to get the LINQ query right to start with :)
If you write your query against a linq-to-sql datacontext, you can get the query text out like this:
CustomDataContext dc = new CustomDataContext(); //your DataContext here.
IQueryable<Customer> customerQuery = GetQuery(dc); //your query constructed here.
Console.WriteLine(dc.GetCommand(customerQuery).CommandText);
Use sql profiler to get the sql as it is executed against the sql database.
精彩评论