title: Counting grouped data with Linq to Sql
body: <p>I have a database of documents in an array, each with an owner and a document type, and I'm trying to get a list of the 5 most common document types for a specific user.</p>
  
  <pre><code>var docTypes = _documentRepository.GetAll()
                     .Where(x =&gt; x.Owner.Id == LoggedInUser.Id)
                     .GroupBy(x =&gt; x.DocumentType.Id);
  </code></pre>
  
  <p>This returns all the documents belonging to a specific owner and grouped as I need them, I now need a way to extract the ids of the most common document types. I'm not too familiar with Linq to Sql, so any help would be great.</p>