下面的查询使用Z.EntityFramework.Plus.EF6筛选子级。其过滤并正确包含AssetXref
实体,但是结果无法包含Child.Parent
实体关系
var result = await _repository.GetQuery<Assets>()
.IncludeFilter(x => x.AssetsXRef
.Where(y => y.Child.Perent.ParentID == parentID)
.Select(y => y.Child.Perent)
)
.Where(x => x.Active == true)
.ToListAsync();
我也尝试过
var result = await _repository.GetQuery<Assets>()
.IncludeFilter(x => x.AssetsXRef
.Where(y => y.Child.Perent.ParentID == parentID)
)
.Include(x=>x.AssetsXRef.Select(y=>y.Child.Parent))
.Where(x => x.Active == true)
.ToListAsync();
答案 0 :(得分:0)
IncludeFilter
与Include
不兼容。即使没有过滤器,您也需要完全使用IncludeFilter
此外,您需要始终在子级上使用完整的父级过滤器
这里是一个例子:
var result = await _repository.GetQuery<Assets>()
.IncludeFilter(x => x.AssetsXRef.Where(y => y.Child.Perent.ParentID == parentID))
// Might be SelectMany
.IncludeFilter(x => x.AssetsXRef.Where(y => y.Child.Perent.ParentID == parentID).Select(y=>y.Child.Parent))
.Where(x => x.Active == true)
.ToListAsync();