Как сделать упорядочивание после группировки?

Мне нужно получить модель с лучшим индексом, но после группировки пишет ошибку:

dbContext.TrainingObjects
  .GroupBy(e => e.ApplicationUserId)
  .Select(e => new { e.Key, Max = e.OrderByDescending(a=>a.Index).FirstOrDefault() })

Но пишет ошибку:

 .OrderByDescending(a => a.Index)' 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()

Не очень понимаю, как можно сделать сортировку по Index после GroupBy??


Ответы (0 шт):