title: aggregation count in linq query returns null
body: <p>I'm implementing asp.net core 3.1 project. In my controller I have a linq query like the following and without defining inprocessapicount and pendingcount which claculates counts of related amounts, it works fine but after adding them to applicants query in select part, applicants returns null and the error is: .Count(a =&gt; a.requestStatus == &quot;bb&quot;) could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to either AsEnumerable(), AsAsyncEnumerable(), ToList(), or ToListAsync() . I appreciate if anyone suggests me a solution.</p>
  <pre><code> var applicants = (from t1 in _context.VwDesk
                                
                                let tg = new {
       
                                     itemID = t1.ItemId,
                                     applicantID = t1.ApplicantId,
                                     applicantName = t1.ApplicantName,
                                   
                                     gateName =t1.GateName,
  
                                     requestStatus = t1.LastReqStatus
                                 }
                                 group tg by new { tg.requestStatus,tg.itemID ,tg.applicantID, tg.applicantName} into ApiAppGp
                                 select new
                                 {
                                     applicantName = ApiAppGp.Key.applicantName,
  
                                     itemname = ApiAppGp.Key.itemID,
   
                                     itemcount =ApiAppGp.Count(),
  
                                     inprocessapicount = ApiAppGp.Where(a =&gt; a.requestStatus == &quot;bb&quot;).Count(),
                                     pendingapicount = ApiAppGp.Where(a =&gt; a.requestStatus == &quot;aa&quot;).Count()
  
  
                                 }).ToList();
  </code></pre>
  <p>What I want is: There are some applicants in Database and each applicant may have multiple or zero requests. (Each applicant orders multiple or zero itemID) each one of those applicants needs to get some item (itemID) and each of those item has requeststatus ==&quot;aa&quot; or requeststatus ==&quot;bb&quot; or none of them which the status in that case is &quot;general&quot;. Now I want to understand, how many each applicant's itemID has requeststatus==&quot;aa&quot; and how many each applicant's itemID has requeststatus==&quot;bb&quot; according to all ItemId they have ordered.</p>