title: How can I use where in select with group by
body: <pre><code>var packs = from r in new XPQuery&lt;Roll&gt;(session)
              join p in new XPQuery&lt;Pack&gt;(session) on r.Pack equals p
              group new { r, p } by new { r.Pack } into gb
              select new
              {
                  Length = gb.Sum(x =&gt; x.r.Length),
                  ALength = gb.Where(a =&gt; a.r.Grade == "A").Sum(x =&gt; x.r.Length),
              };
  
  gcPack.DataSource = packs;
  </code></pre>
  
  <p>I know <code>ALenght = gb.Where(a =&gt; a.r.Grade == "A").Sum(x =&gt; x.r.Lenght)</code> causes runtime error and without it the code is ok. Is it possible to use where in select statement like this.</p>
  
  <p>Error: </p>
  
  <blockquote>
    <p>Additional information: Property path 'r' is incorrect for type 'DataRepository.Roll' because member 'DataRepository.Roll.r' does not exist.</p>
  </blockquote>