title: GroupBy Expression failed to translate
body: <pre><code>//Model
  public class Application
  {
      [Key]
      public int ApplicationId { get; set; }
      public DateTime CreatedAt { get; set; }
      public DateTime ConfirmedDate { get; set; }
      public DateTime IssuedDate { get; set; }
      public int? AddedByUserId { get; set; }
      public virtual User AddedByUser { get; set; }
      public int? UpdatedByUserId { get; set; }
      public virtual User UpdatedByuser { get; set; }
      public string FirstName { get; set; }
      public string MiddleName { get; set; }
      public string LastName { get; set; }
      public string TRN { get; set; }
      public string EmailAddress { get; set; }
      public string Address { get; set; }
      public int ParishId { get; set; }
      public Parish Parish { get; set; }
      public int? BranchIssuedId { get; set; }
      public BranchLocation BranchIssued { get; set; }
      public int? BranchReceivedId { get; set; }
      public BranchLocation BranchReceived {get; set; }
  }
  
  public async Task&lt;List&lt;Application&gt;&gt; GetApplicationsByNameAsync(string name)
  {
      if (string.IsNullOrEmpty(name))
          return null;
      return await _context.Application
          .AsNoTracking()
          .Include(app =&gt; app.BranchIssued)
          .Include(app =&gt; app.BranchReceived)
          .Include(app =&gt; app.Parish)
          .Where(app =&gt; app.LastName.ToLower().Contains(name.ToLower()) || app.FirstName.ToLower()
          .Contains(name.ToLower()))
          .GroupBy(app =&gt; new { app.TRN, app })
          .Select(x =&gt; x.Key.app)
          .ToListAsync()
          .ConfigureAwait(false);
  }
  </code></pre>
  
  <p>The above <code>GroupBy</code> expression fails to compile in VS Studio. My objective is to run a query filtering results by name containing a user given string and then it should group the results by similar <code>TRN</code> numbers returning a list of those applications to return to the view. I think I am really close but just cant seem to figure out this last bit of the query. Any guidance is appreciated.</p>
  
  <p>Error being presented</p>
  
  <pre><code>InvalidOperationException: The LINQ expression 'DbSet&lt;Application&gt;
  .Where(a =&gt; a.LastName.ToLower().Contains(__ToLower_0) || a.FirstName.ToLower().Contains(__ToLower_0))
  .GroupBy(
  source: a =&gt; new {
  TRN = a.TRN,
  app = a
  },
  keySelector: a =&gt; a)' 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()
  </code></pre>
  
  <p><strong>UPDATE</strong>
  Seems it is definitely due to a change in how .net core 3.x and EF core play together since recent updates. I had to change it to client evaluation by using <code>AsEnumerable()</code> instead of <code>ToListAsync()</code>. The rest of the query given by Steve py works with this method. I was unaware even after reading docs how the groupby really worked in LINQ, so that has helped me a lot. Taking the query to client side eval may have performance issues however.</p>