我有一个使用两个SQL表(A和B)的数据上下文,这些表使用以下代码查询:
var query = from b in _ctx.A
.Where(b => b.Flag == true).Include(c => c.B)
select b;
Flag列位于表A中。我想向查询中添加一个附加的where子句,该子句检查表B中名为Qty的列的值> 10。
我尝试了以下代码,但出现错误:
var query = from b in _ctx.A
.Where(b => b.Flag == true)
.Include(c => c.B.Where(i => i.Qty >= 10))
select b;
错误:包含路径表达式必须引用在类型上定义的导航属性。使用虚线路径作为参考导航属性,使用“选择”运算符作为集合导航属性。参数名称:路径
我发现此参考:The Include path expression must refer to a navigation property defined on the type.in eager loading
但是我不明白如何在查询中使用选择。