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
{{ message }}
Repository navigation
Question: SQL LEFT JOIN clause varies based on declarative- vs. method-style join #3176
fromfooindbContext.Set<Foo>()
join barindbContext.Set<Bar>() on
new{foo.Id,State="Blah"} equals new{Id=bar.FooId,bar.State} into barGroupJoinfromsubBarinbarGroupJoin.DefaultIfEmpty()selectnew{/* use subBar instead of bar */}
Method-style equijoin
fromfooindbContext.Set<Foo>()frombarindbContext.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"
changed the title [-]SQL LEFT JOIN clause varies based on declarative- vs. method-style join[/-][+]Question: SQL LEFT JOIN clause varies based on declarative- vs. method-style join[/+]on May 17, 2024
Activity
[-]SQL LEFT JOIN clause varies based on declarative- vs. method-style join[/-][+]Question: SQL LEFT JOIN clause varies based on declarative- vs. method-style join[/+]roji commentedon May 17, 2024
This is a general SQL translation question that isn't related to the PostgreSQL provider, can you please move it to https://github.com/dotnet/efcore?