title: Return 2 columns, Id and count, from EF as Dictionary<int,int>
body: <p>I have an FK relationship between two tables, but for the purpose of this query, I need to get a count of rows for each FK. </p>
  
  <p>For example, I have a <code>CareTaker</code> table With <code>CareTakerId</code> as PK; and an <code>Animal</code> table with <code>CareTakerId</code> as FK. Given a list of <code>CareTakerIds</code>, I want All AnimalIds that each care taker is responsible for. Something like this: </p>
  
  <pre><code>select CareTakerId, count(1) 
  from Animal
  where CareTakerId in (1,2,3,4)
      and AnimalTypeId = 3
  group by CareTakerId
  </code></pre>
  
  <p>Which returns </p>
  
  <pre><code>CareTakerId | No ColumnName
  1           | 42
  2           | 6
  </code></pre>
  
  <p>How do I do this in EntityFramework? 
  I need this result, so I thought I'd do it as a <code>Dictionary&lt;int,int&gt;</code> (<code>Dictionary&lt;CareTakerId,Count&gt;</code>) - but  I cannot figure out how to write the EF query for it.. Here's what I have so far: </p>
  
  <pre><code>query
      .Where(r =&gt; r.AnimalTypeId == animalTypeId 
               &amp;&amp; careTakerIds.Contains(r =&gt; r.CareTakerId))
      .GroupBy(r =&gt; r.CareTakerId)
      // Not sure what to write here; r.CareTakerId doesn't exist
      .Select(r =&gt; new {r.key, r.value }) 
      .ToDictionary(kvp =&gt; kvp.Key, kvp =&gt; kvp.value);
  </code></pre>
  
  <p>How do I select <code>CareTakerId</code> and count(1) in entity framework please? </p>