2

Is anyone heard of any tool writing LINQ queries and converting them to SQL queries?

I mostly need this because I am a .NET developer and I'm weak in this section of SQL queries where sometimes I need them.

Thank you.

3 Answers 3

4

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 :)

Sign up to request clarification or add additional context in comments.

2 Comments

it's worth noting that you'll have to pay for Autocomplete in LINQPad, that's why I still use VS to test my LINQ
I think LINQPad would be great if i can se the generated SQL Query. Will try and get back to the thread. :)
4

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);

1 Comment

This requires code inside every project, I need an external tool to test on the fly.
0

Use sql profiler to get the sql as it is executed against the sql database.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.