title: Generate a SQL clause using a Linq-to-Sql Expression
body: <p>I would like to create a repository model that could take an Expression and use Linq-To-Sql to generate the required SQL statement.</p>
  
  <p>For example, I have a function such as this:</p>
  
  <pre><code>// Possible criteria
  Expression&lt;Func&lt;Purchase,bool&gt;&gt; criteria1 = p =&gt; p.Price &gt; 1000;
  
  // Function that should take that criteria and convert to SQL statement
  static IEnumerable&lt;Customer&gt; GetCustomers (Expression&lt;Func&lt;Purchase,bool&gt;&gt; criteria)
  {
     // ...
  }
  </code></pre>
  
  <p>Inside the function, I would like to convert criteria to a SQL statement using Linq-To-Sql.</p>
  
  <p>I am aware that you can use <code>DataContext.Log</code> to see the executed queries and <code>DataContext.GetCommand(query).CommandText</code> to see the full query before it is executed.  However, I would like just a part of the entire expression generated.</p>
  
  <p>What I am hoping to accomplish is to make my repository abstract the underlying technology (Linq-to-Sql, Dapper, etc). That way I could pass the Expression to the repository, have it generate the right statement and use the right technology to execute it.</p>