title: LINQ JOIN + GROUP BY + SUM
body: <p>I have two LINQ statements that I would like to make into one, but for the life of me I can't get it to work.</p>
  
  <p>I can't get the grouping to work in the first statement.
  It complains that the <code>TotalBuy</code> and <code>TotalSell</code> properties aren't there, although doesn't complain about <code>AmountTC</code> and <code>AmountAUD</code>.</p>
  
  <p>This should be simple. Any thoughts?</p>
  
  <pre><code>var itineraryItems =
      from ii in this.ItineraryItemRecords
      join t in this.TransactionRecords on ii.OperatorID equals t.
      TransactionActor.OperatorID into g select new {
      OperatorID = ii.OperatorID, TotalBuy = g.Sum(i = &gt;ii.TotalBuy)
          , TotalSell = g.Sum(i = &gt;ii.TotalSell)
          , PaidTC = (0 - (g.Sum(t = &gt;t.AmountTC)))
          , PaidAUD = (0 - (g.Sum(t = &gt;t.AmountAUD)))
  };
  
  var itineraryItemz =
      from i in itineraryItems group i by i.OperatorID into g select new {
      OperatorID = g.Key, TotalBuy = g.Sum(i = &gt;i.TotalBuy)
          , TotalSell = g.Sum(i = &gt;i.TotalSell)
          , PaidTC = (0 - (g.Sum(i = &gt;i.PaidTC)))
          , PaidAUD = (0 - (g.Sum(i = &gt;i.PaidAUD)))
  };
  </code></pre>
  
  <p>As a side note, <code>ItineraryItemRecords</code> and <code>TransactionRecords</code> are Collections of classes handled by <code>SubSonic</code>.</p>
  
  <p>This really should be simple, so any help would be appreciated.</p>
  
  <p>Regards,
  John</p>