开发者

LINQ query to SQL Script

开发者 https://www.devze.com 2023-02-05 00:00 出处:网络
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 quer

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消