C# 使用EntityFrameworkPlus IncludeFilter在Include上过滤
我尝试向下筛选三个子级别,并查找propertyMailGadAddress.Status==True的唯一子元素 如何将过滤器向下转换三个级别,并使用EntityFrameworkPlus IncludeFilter执行嵌套过滤?最有效的方法是什么 类结构嵌套如下:C# 使用EntityFrameworkPlus IncludeFilter在Include上过滤,c#,.net,linq,.net-core,entity-framework-plus,C#,.net,Linq,.net Core,Entity Framework Plus,我尝试向下筛选三个子级别,并查找propertyMailGadAddress.Status==True的唯一子元素 如何将过滤器向下转换三个级别,并使用EntityFrameworkPlus IncludeFilter执行嵌套过滤?最有效的方法是什么 类结构嵌套如下: var result = await db.Property.IncludeFilter(pm => pm.PropertyParty .Select(x =&
var result = await db.Property.IncludeFilter(pm => pm.PropertyParty
.Select(x => x.Party)
.SelectMany(x => x.PartyMailingAddress)
.SelectMany(x => x.PropertyMailingAddress.Where(z => z.Status == true)).ToListAsync();
包含与包含过滤器混用
在EF Core中,IncludeFilter
应自动添加所有路径
我们没有类定义,因此很难准确了解关系,但查询应如下所示:
var result = await db.Property.IncludeFilter(pm => pm.PropertyParty
.Select(x => x.Party)
.SelectMany(x => x.PartyMailingAddress)
.SelectMany(x => x.PropertyMailingAddress.Where(z => z.Status == true)).ToListAsync();
过滤在数据库中完成。所以要小心使用EF Core 2.x,因为他们在EF Core 3.x中删除了客户端评估,这导致了一些问题
如果您需要更多帮助,请在我们的问题跟踪器中提供一个可运行的解决方案:您可以附加您的类定义吗?嗨,Jon,我需要相关的实体,答案中有过滤器,您的答案只包含过滤器,谢谢
var result = await db.Property.IncludeFilter(pm => pm.PropertyParty
.Select(x => x.Party)
.SelectMany(x => x.PartyMailingAddress)
.SelectMany(x => x.PropertyMailingAddress.Where(z => z.Status == true)).ToListAsync();