You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromfooin dbContext.Set<Foo>()
join bar in dbContext.Set<Bar>() on
new{ foo.Id, State ="Blah"} equals new{ Id = bar.FooId, bar.State } into barGroupJoin
fromsubBarin barGroupJoin.DefaultIfEmpty()selectnew{/* use subBar instead of bar */}
Method-style equijoin
fromfooin dbContext.Set<Foo>()frombarin dbContext.Set<Bar>().Where(x => x.FooId == foo.Id && x.State =="Blah").DefaultIfEmpty()selectnew{/* use bar */}
I generally prefer 2 because it's arguably just as easy to read, doesn't leave a variable that goes unused, etc.
But one thing I notice is that the former style will generate something like
LEFT JOIN mySchema."Bars"AS B ON B."FooId"= F."Id"AND B."State"='Blah'
while the latter generates something like
LEFT JOIN (
SELECT …
FROM mySchema."Bars"AS B
WHERE B."State"='Blah'
) as C ON C."FooId"= F."Id"
Redirected here from npgsql/efcore.pg#3176
I generally prefer 2 because it's arguably just as easy to read, doesn't leave a variable that goes unused, etc.
But one thing I notice is that the former style will generate something like
while the latter generates something like
Is this intentional, and if so why?
Include provider and version information
EF Core version: 8.0.4
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: .NET 8
Operating system: MacOS Sonoma 14.4.1
IDE: Rider
The text was updated successfully, but these errors were encountered: