title: How to cast a Linq Dynamic Query result as a custom class?
body: <p>Normally, I do this:</p>
  
  <pre><code>var a = from   p in db.Products
          where  p.ProductType == "Tee Shirt"
          group  p by p.ProductColor into g
          select new Category { 
                 PropertyType = g.Key,
                 Count = g.Count() }
  </code></pre>
  
  <p>But I have code like this:</p>
  
  <pre><code>var a = Products
          .Where("ProductType == @0", "Tee Shirt")
          .GroupBy("ProductColor", "it")
          .Select("new ( Key, it.Count() as int )");
  </code></pre>
  
  <p><strong>What syntax could I alter to produce identical results, i.e., how do I do a projection of Category from the second Linq statement?</strong></p>
  
  <p>I know in both that <em>g</em> and <em>it</em> are the same and represent the entire table record, and that <strike>I am pulling the entire record in just to do a count.  I need to fix that too.</strike>  Edit: Marcelo Cantos pointed out that Linq is smart enough to not pull unnecessary data.  Thanks!</p>