Describe what is not working as expected.
Doing outer joins is with linq are horrible and make for a mess of code that makes it difficult if not impossible to debug.
I.e:
from c in Context.Courses
join ci in Context.CourseItems on c.Id equals ci.CourseId
join tijoin in Context.TopicItems on ci.ItemId equals tijoin.TopicId into titrans
from ti in titrans.DefaultIfEmpty()
By adding leftjoin we'd get this:
from c in Context.Courses
join ci in Context.CourseItems on c.Id equals ci.CourseId
leftjoin ti in Context.TopicItems on ci.ItemId equals ti.TopicId
Yes it really is that ugly every single time simply because there isn't a leftjoin operator that does the same.
Would this break current providers? No, because it can be converted first to the ugly syntax they already support if they don't support the new stuff.
Would this slow anything down? Nope. Same stuff generated.
Would this introduce bugs in code? Nope, this is a new keyword that is highly likely to not be used in someone's code that would cause problems.
I'm very sure that this syntax is also causing developers to write bad code (because I've seen it) doing the following:
from c in Context.Courses
join ci in Context.CourseItems on c.Id equals ci.CourseId
let ti = (from i in Context.TopicItems where i.TopicId == ci.ItemId select I)
Which results in a sub select disaster which is INCREDIBLY SLOW.
Please save us from our insanity and work with the C# team to get this keyword added and make Entity Framework sane for left outer joins! (all right outer joins can be written as lefts so no need to confuse the matter)
This would be extremely helpful!
Yes! we every write left join query as below, this is not clear and not expectable what is mean.
_context.Users
.GroupJoin(_context.Posts, u => u.Id, p => p.UserId, posts => posts.DefaultIfEmpty())
.SelectMany(g => new {User = g.Key, Posts = g.Value})
.Something();
maybe we want to use as ..
_context.Users
.LeftJoin(_context.Posts. u => u.Id, p => p.UserId, (user, post/* nullable? */) => new {user, post})
.Where(/* something */);
StackOverflow returns 1,337 results for "LEFT JOIN in LINQ". Yes, we need it, and not only in EF Core but also for LINQ-to-objects.
Most helpful comment
StackOverflow returns 1,337 results for "LEFT JOIN in LINQ". Yes, we need it, and not only in EF Core but also for LINQ-to-objects.