Mus*_*med 8 c# linq-to-entities entity-framework-core asp.net-core-3.1 entity-framework-core-3.1
我正在尝试在 EF 核心 3.1 中分组加入它返回的问题
处理 LINQ 表达式 'DbSet 失败。这可能表明 EF Core 中存在错误或限制
我的代码是这样的
var employees = await (from enrollment in RepositoryContext.Enrollments
join allowance in RepositoryContext.Allowances.Include(y=>y.AllowanceType) on enrollment.EmployeeId equals allowance.EmployeeId
into allowances
select new
{
enrollment,
allowances
}
).AsNoTracking().ToListAsync();
Run Code Online (Sandbox Code Playgroud)
该津贴是项目的清单,有没有什么解决办法运行这样的,因为我需要它更好berformance查询。
这里Query with GroupBy 或 GroupJoin throws exception是现在关闭的 GitHub 问题/讨论,我试图说服 EF Core 团队添加GroupJoin
翻译。他们拒绝这样做并打开了无用的Query: Support GroupJoin 当它是最终查询操作符 #19930 时,我继续为这种翻译而战。所以请去那里评论/投票支持完整的翻译请求。
您还会在那里找到解决方法 - 而不是不受支持的GroupJoin
使用等效支持的相关子查询方法,例如替换
join allowance in RepositoryContext.Allowances.Include(y => y.AllowanceType)
on enrollment.EmployeeId equals allowance.EmployeeId
into allowances
Run Code Online (Sandbox Code Playgroud)
和
let allowances = RepositoryContext.Allowances.Include(y => y.AllowanceType)
.Where(allowance => enrollment.EmployeeId == allowance.EmployeeId)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3617 次 |
最近记录: |