title: EF Core Grouping Multiple Joined Tables
body: <p>I am getting an error at runtime when trying to group on 3 tables that have been joined together. I know i can do this in sql but i'm trying to keep to EF Core if at all possible. EF Core complains that the linq expression could not be translated or that i would need to switch to client side evaluation. The goal is to have this simple join and grouping run in the sql server.</p>
  <pre><code>from line in _context.OrderLines
      join item in _context.Items on line.ItemId equals item.ItemId
      join supplier in _context.Suppliers on item.SupplierId equals supplier.SupplierId
  group line by supplier.Name
  </code></pre>
  <p>The grouping above is a valid Query Expression at compile time and will fail without the subsequent select but to elaborate on my end usage: I want to be able to sum my line quantities by the supplier. This should be a simple aggregation after the grouping.</p>
  <pre><code>from line in _context.OrderLines
      join item in _context.Items on line.ItemId equals item.ItemId
      join supplier in _context.Suppliers on item.SupplierId equals supplier.SupplierId
  group line by supplier.Name into lineGrouping
  select new { Name = lineGrouping.Key, Qty = lineGrouping.Sum(x =&gt; x.Qty) }
  </code></pre>
  <p>The execution results in the following error:</p>
  <p>System.InvalidOperationException: Client side GroupBy is not supported.
  at
  Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.CustomShaperCompilingExpressionVisitor.VisitExtension(Expression extensionExpression)</p>