Group by with DefaultIfEmpty on a sub-query with a left join changes the subquery's joins to inner joins #27480
Labels
area-groupby
area-query
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-bug
Milestone
File a bug
The projection starts of being correct, but after joining to it using
DefaultIfEmpty()
the resulting query ends up incorrect. This only seems to happen when usingfrom x in db.xx.Where().DefaultIfEmpty()
syntax to join,join x in db.xx
version seems okay (see below).So, this sample code using
Microsoft.EntityFrameworkCore.Sqlite
but this also happens inMicrosoft.EntityFrameworkCore.SqlServer
. I've attached the full project here: Console3.zipProduces the following output:
As you can see the inner most join is changed for a left join to an inner join.
I've found that using more traditional join syntax produces the correct SQL. So this works:
Include provider and version information
EF Core version: 6.0.2 (and I've confirmed it exists in 6.0.0 and 6.0.1)
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Windows 11
IDE: VSCode 1.64.2
The text was updated successfully, but these errors were encountered: