Search code examples
linqpad

LinqPad - Convert SQL to Linq command


I recently purchased LINQPad in hopes that it would allow me to convert SQL statements into LINQ statements.

Using LINQPad, I am able to attach a DB and run the SQL statement which returns the results I need.

But I can not find a 'command' to convert that SQL statement into LINQ.

Can you please let me know how to convert SQL to LINQ by using LINQPad OR another tool?


Solution

  • In general there are no tools to covert SQL to Linq as @andres-abel mention before, but sometimes you have to write Linq that will execute exactly as specified SQL (for example because of performance issues, backward compatability or some other reasons).

    In this case I'll advice you to do reverse engineering by yourself:

    1. configure logging of dump SQL statements generated by Linq to stdout using
    2. manually rewrite Linq statement until you'll get what you need