title: Pass in an Expression to linq's Select
body: <p>This is <strong>linq-to-sql</strong></p>
  
  <p>I have a lot of different classes all doing the same query, but projecting the results slightly differently.  Ideally I'd like to be able to have the query in one place, and have the projection passed into the Select method.  It works fine for concrete types:</p>
  
  <pre><code>public void GetResults() {
      var junk = db.SiteProducts.Select(Project());
  }
  
  public Expression&lt;Func&lt;DbEntities.SiteProduct, string&gt;&gt; Project() {
      return p =&gt; p.ProductAlert;
  }
  </code></pre>
  
  <p>But when I try to return an anonymous type, it fails</p>
  
  <pre><code>public void GetResults() {
      var junk = db.SiteProducts.Select(Project());
  }
  
  public Expression&lt;Func&lt;DbEntities.SiteProduct, TResult&gt;&gt; Project&lt;TResult&gt;() {
      return p =&gt; new { p.ProductAlert };
  }
  </code></pre>
  
  <p>I fully understand why generic type inference is failing in the second case.  But is there a trick—short of crafting my own Expressions from the ground up—I'm missing that could get this to work?</p>