title: Extract sql query from LINQ expressions
body: <p><strong>Is it possible to extract sql statements from LINQ queries ?</strong></p>
  <p>Say, I have this LINQ expression.</p>
  <pre><code>        string[] names =
              new string[] { &quot;Jon Skeet&quot;, &quot;Marc Gravell&quot;, &quot;tvanfosson&quot;, 
                             &quot;cletus&quot;, &quot;Greg Hewgill&quot;, &quot;JaredPar&quot; };
  
          var results = from name in names
                        where name.StartsWith(&quot;J&quot;)
                        select name;
  </code></pre>
  <p><a href="http://ruchitsurati.net/files/linq-debugging.png" rel="nofollow noreferrer">alt text http://ruchitsurati.net/files/linq-debugging.png</a></p>
  <p>After this statement 'results' is only holding the LINQ expression and not the results due to deferred execution of LINQ queries.</p>
  <blockquote>
  <p><strong>Can I extract or produce the LINQ query out of 'results' and
  prepare a valid SQL statement from the
  query stored in 'LINQ'?</strong></p>
  </blockquote>
  <h2>EDIT</h2>
  <p>Here's My objective:</p>
  <p>We have written our own ORM. We have to write queries every-time we need to do db operations. Now we need to get rid of it at DAL. We wish to write LINQ expression in code which will produce SQL statements against my ORM and we will execute this SQL on the database.</p>
  <p><strong>Will I haev to write my custom Linq Providers to do what I need ?</strong></p>