title: Loading LINQ results into a ViewModel that has a calculated attribute (column)
body: <p>I've seen the scenarios where a ViewModel is populated with one LINQ query as shown below. <strong>Question</strong>: How can I populate the <code>TotalSale</code> attribute (column) - that is a grand total of Sale column - of the following ViewModel? <strong>Note</strong>: I'm using latest version of ASP.NET Core with VS2015. </p>
  
  <p><strong>ViewModel:</strong></p>
  
  <pre><code>public class CategProdViewModel
  {
      public string Category { get; set; }
      public string ProductName { get; set; }
      public float Sale { get; set; }
      public float TotalSale { get; set; }
  }
  </code></pre>
  
  <p><strong>Controller</strong>:</p>
  
  <pre><code>var innerJoinQuery =  from category in categories
         join prod in products on category.ID equals prod.CategoryID
         select new CategProdViewModel { Category = category.Name, ProductName = prod.Name, Sale = prod.Sale }; 
  </code></pre>