我有两个实体EntityTest
和EntityRelated
。
我想查询并获取两个Entites中两个Entted都不为真的Entites的结果。
我试过以下声明。它通过排除Deleted = true的记录返回EntityTest记录,但不过滤EntityRelated的记录。
db.EntityTest
.Include(i => i.EntityRelated)
.Where(x => x.Deleted != true && x.EntityRelated.Any(a => a.Deleted != true).ToList();
答案 0 :(得分:0)
解决方案1:使用扩展方法Include2()Include2的此实现。如下:
db.EntityTest
.Include(i => i.EntityRelated.Where(e=>e.Deleted == false))
.Where(x => x.Deleted != true && x.EntityRelated.Any(a => a.Deleted != true)
.ToList();
解决方案1: