title: Linq - Grouping with sum calculation
body: <p>Linq noob here. How do I correct this?</p>
  
  <pre><code>                var result = (from row in rulestable.AsEnumerable()
                           let sup = row.Field&lt;int&gt;("Supplier")
                           let amo = row.Field&lt;decimal&gt;("Amount")
                           let adv = row.Field&lt;decimal&gt;("Advance")
                           let bal = row.Field&lt;decimal&gt;("Balance")
                           let vat = row.Field&lt;decimal&gt;("VatRate")
                           group row by new { sup, vat } into grp
                           select new
                           {
                               Supplier = grp.Key.sup,
                               Amount = grp.Sum(grp =&gt; grp["amo"]),
                               Advance = grp.Sum(grp =&gt; grp["adv"]),
                               Balance = grp.Sum(grp =&gt; grp["bal"]),
                               VatRate = grp.Key.vat
                           }).ToList();
  </code></pre>
  
  <p>I want to group my datatable "rulestable" on 2 columns, Supplier and VatRate. The Amount, Advance and Balance of the result must be set to the sum of whatever columns were grouped.</p>
  
  <p>I get an error - "the type arguments cannot be inferred from the usage" on grp.Sum. However, I think this expression is all wrong - I think it will sum the result columns and not the source columns like I want.</p>
  
  <p>Example:</p>
  
  <p>Input DataTable:<br />
  Supplier, Amount, Advance, Balance, VatRate<br />
  S1, 10, 5, 5, 1<br />
  S1, 10, 5, 5, 1<br /></p>
  
  <p>Expected output:<br />
  S1, 20, 10, 10, 1</p>
  
  <hr>
  
  <p>What's the best way to do this?</p>