【发布时间】:2022-01-27 01:12:16
【问题描述】:
我正在使用 EF Core 6.0 框架。我正在编写 Web API。我想像下面的代码一样加入城市和城镇实体。
但是如果我在 LinQ 查询中像这样“into tmpTownArr”这样使用“into”字,程序就会崩溃(它给 GroupJoin Error,我写在图片下面)
在下面的图片 1 和 3 不工作,但 No 2 和 4 工作
1号错误代码:
The LINQ expression 'DbSet<City>()
.GroupJoin(
inner: DbSet<Town>(),
outerKeySelector: c => c.Id,
innerKeySelector: t => t.CityId,
resultSelector: (c, tmpTownArr) => new {
c = c,
tmpTownArr = tmpTownArr
})' 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 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
【问题讨论】:
-
您能否将代码发布为文本而不是屏幕截图?将您的 插入为 cmets。
-
我想,我怕是的... :(( (Svyatoslav Danyliv)
标签: c# api linq left-join ef-core-6.0