Following this problem with filtering Include in EF Core:
is this something that will be possible in EF 3.0?
By default, EF Core doesn't support to filter in the Include
method.
Disclaimer: I'm the owner of the project Entity Framework Plus
The EF+ Query IncludeFilter (free and open source) allows easily filter included entities.
The ThenInclude
is not yet supported but you just have to include the last filter to have the same behavior.
Example:
_dbContext.User
.IncludeFilter(x=>x.UserRoles)
.IncludeFilter(x=>x.UserRoles.SelectMany(y => y.Roles.Where(z => z.Active)))