title: Sums of Linq values in select
body: <p>So I have always came across this situation when using linq. Say I have code like below:</p>
  
  <pre><code>            var results = _context.Products.Select(d =&gt;
              new Models.ProductData()
              {
                  Id = d.ProductId,
                  Name = d.Product.Name,
                  Qty = d.Number.Where(y =&gt; y.Active &amp;&amp; y.CodeId == 5 &amp;&amp; y.Status == "NEW").Sum(y =&gt; y.FeeAmount),
                  Qty1= d.Number.Where(y =&gt; y.Active &amp;&amp; y.CodeId == 7 &amp;&amp; y.Status == "NEW").Sum(y =&gt; y.Fee),
                  Total = d.Number.Where(y =&gt; y.Active &amp;&amp; y.CodeId == 5 &amp;&amp; y.Status == "NEW").Sum(y =&gt; y.FeeAmount) + d.Number.Where(y =&gt; y.Active &amp;&amp; y.CodeId == 7 &amp;&amp; y.Status == "NEW").Sum(y =&gt; y.Fee)
              }
              );
  </code></pre>
  
  <p>For the total value, is there a better way to calculate the total without having to write out all the linq statements with + symbols in between? It would be a lot nicer to be able to write something like </p>
  
  <pre><code>Total = Qty + Qty1
  </code></pre>
  
  <p>I could omit the total from the initial mapping and the remap it grouping by Id and assigning the totals there by referencing Total = Qty + Qty1 but that just seems to round about.</p>
  
  <p>Any suggestions are appreciated.</p>