title: get top 5 frequent values and their total count Linq-to-Sql
body: <p>i am using this Linq to sql to get most appearing records. </p>
  
  <pre><code>List&lt;int&gt; result;
  result = await context.InvoiceItems.GroupBy(q =&gt; q.ProductID)
          .OrderByDescending(gp =&gt; gp.Count())
          .Take(5)
          .Select(g =&gt; g.Key).ToListAsync();  
  </code></pre>
  
  <p>and getting int type values. but i want also to get total number of times each value is occurred. like this SQL query is returning.  </p>
  
  <pre><code>select productID, Count(*) AS value_occurrence from InvoiceItems group by productID  
  </code></pre>
  
  <p>see this table image</p>
  
  <p><a href="https://i.stack.imgur.com/3Jnnh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Jnnh.jpg" alt="SQL results"></a></p>