I am using EF core 2.0 and would like to filter the child collection. Can anyone help me how to do this in EF core 2.0?
var items = await _context.RiskType .Include(r => r.Categories) .ThenInclude(category => category.Alerts) .ToListAsync();
In the above code i want to filter
Use EF plus and this works. You may filter on either level. https://entityframework-plus.net/query-include-filter
var items = ctx.RiskType.IncludeFilter(r=>r.Categories).IncludeFilter(x => x.Categories.Select(p=>p.Alerts.Where(alert=>alert.caseId==1))) .ToList();
This works like Include with filter which applies on database level (you see it in db profiler).