EF Core eager loading collections when GroupBy used after Include
var productsByRecalls = await _context .Products .Include(x => x.Suppliers) // <—– .Include(x => x.Recalls) // <—– .AsSplitQuery() .OrderBy(x => x.CreatedAt) .Where(x => x.Status == ProductStatus.Approved) .GroupBy(x => x.Recalls) // <—– .Where(x => x.Any()).Select(x => x.SingleOrDefault()) .ToListAsync(); Without grouping that works as expected, and the Include collections are eager loaded. But when using grouping, the Suppliers […]
EF Core workaround for DistinctBy causes other errors
A query: