title: How to shorten the LINQ query to calculate the sum for parent table from child tables
body: <p>Currently I have this LINQ query which calculate the totalcount of a parent table (<code>CafeTables</code>) from child tables (<code>CafeTableDetails</code>). These code works. But somehow, I believe these code can the shorten.</p>
  
  <pre><code>var selectedTable = db.CafeTables.Where(c =&gt; c.TableNo.Equals(userName)).SingleOrDefault();
  
  var selectedTableDetailsRaw = db.CafeTableDetails.
      Where(cd =&gt; cd.CafeTableId == selectedTable.Id);
  
  selectedTable.TotalOrders = selectedTableDetailsRaw.Count();
  </code></pre>