-
Couldn't load subscription status.
- Fork 3.3k
Description
Issue Description:
Hello EF Core team,
I've encountered what seems to be a bug in EF Core 9. When I perform a GroupJoin between two tables using a condition that always evaluates to true (for example, c => true and p => true), the resulting joined collection is always null, even though there are valid entries in the related table. Here is minimal reproducible example:
var query = context.Categories
.GroupJoin(context.Products,
c => true,
p => true,
(c, p) => new
{
Category = c,
Products = p
})
.Select(s => new
{
CategoryName = s.Category.CategoryName,
Products = s.Products
})
.ToList();In this scenario, s.Products always comes back as empty (null), However, if I rewrite this using a from clause (or a manual join with on 1 equals 1), I get the expected results:
var query2 =
(from c in context.Categories
join p in context.Products
on 1 equals 1
into productGroup
select new
{
CategoryName = c.CategoryName,
Products = productGroup
})
.ToList();Both of these queries should logically produce the same result, but the GroupJoin version returns null for the Products while the LINQ from version successfully includes the product collection. If this is not intended behavior, it seems like a bug.
Thank you for looking into this! If you need any further information I'm happy to provide more details.