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
and Recalls
collections are empty.
Why does this happen, and how can I include them?