The query below is using Z.EntityFramework.Plus.EF6 to filter children. Its filtering and including the AssetXref
entity correctly however the result is not able to include Child.Parent
entity relationship
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();
I have also tried
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();
The IncludeFilter
is not compatible with Include
. You need to use IncludeFilter
all the way even if there is no filter
In addition, you need to always use the full parent filter on child
Here is an example:
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();