title: Combining 2 linq queries - group and join
body: <p>I have 2 separate tables in my Db for Customers and their related Ethnicity. The customers table holds foreign key Id for the ethnicity. I would like to create a Linq query that shows the total of each ethnicity for reporting purposes. For example something like...</p>
  
  <pre><code> +------------+------------------+
   |  Ethnicity | Customer Count   |
   +------------+------------------+
   |  White     |   100            |
   +------------+------------------+
   |  Black     |   50             |
   +------------+------------------+
   |  Chinese   |   20             |
   +------------+------------------+ etc...
  </code></pre>
  
  <p>So far I have the following two LINQ queries:</p>
  
  <pre><code>var customers = repository.GetAll&lt;Customer&gt;();
  var ethnicities = repository.GetAll&lt;Ethnicity&gt;();
  
  var query1 = customers.GroupBy(c =&gt; c.EthnicityId).Select(g =&gt; new { Key = g.Key, Count = g.Count() });
  </code></pre>
  
  <p>query 1 shows totals but with ethnicity ID instead of text (EthnicityType).</p>
  
  <pre><code>var query2 = from c in customers
               join e in ethnicities on c.EthnicityId equals e.Id
               where (c.EthnicityId == e.Id)
               select new { Ethnicity = e.EthnicityType, Count = ??? };
  </code></pre>
  
  <p>query 2 joins the two tables but how to group this so that I get the Total instead of individual records? Hope this makes sense, would appreciate help on this.</p>