Client side GroupBy is not supported

﹥>﹥吖頭↗ 提交于 2019-12-04 03:44:52

Your .GroupBy(y => y.LanguageCode).ToDictionaryAsync(y => y.Key, y => y.Select(z => z.Name)); cannot be converted to SQL. EF Core 3.0 will throw exception to make sure you know that all records in Units will be fetched from database before grouping and map to Dictionary.

It's top breaking change in EF Core 3.0. https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes

Apparently it's not yet supported in EF Core 3.0, that is, it is not supported to perform GroupBy over SQL.

One possible solution (works for me) is to make the GroupBy on a List object.

var units = (
  await context.Units
  .SelectMany(y => y.UnitsI18N)
  .GroupBy(y => y.LanguageCode)
  .ToDictionaryAsync(y => y.Key, y => y.Select(z => z.Name))
  ).ToList().OrderBy(y => y.Name);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!