title: LINQ query to output key count value pairs
body: <p>There are about half a million RavenDB documents of Customers. One of the properties is "City".. how can I write a LINQ query to get a list of all occurence of a each city with its count. For example, if a thousand customer documents have "NY" as city value, then I need a list of cities with count like NY 1000; LA 200, OR 1300 , BO 5000 etc..</p>
  
  <p>This is what I wrote initially..</p>
  
  <pre><code> Dictionary&lt;string,int&gt; cityStats = session.Query&lt;Customer&gt;()
                      .ToList()
                      .GroupBy(x =&gt; x.City)
                      .OrderBy(x =&gt; x.Count())
                      .ToDictionary(x =&gt; x.Key, x =&gt; x.Count());
  </code></pre>
  
  <p>But this does not look like its giving me accurate results.. so i changed the maximum requests allowed property (I know its not recommended) just to see if it changes the result.. but keeping maxrequest value to 500000 also brings me same result. I know for sure there are about half a million customer documents , so it needs to add up to match.</p>