question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LeftJoin with Linq fluent syntax?

See original GitHub issue

All the Join examples on the wiki use linq’s query syntax (eg: from u in Users select u.Name), but I’m used to the fluent/method syntax (eg: Users.Select(u => u.Name)).

Why can’t I do something like the following:

db.Users.LeftJoin(db.Posts, u => u.Id, p => p.UserId);

Something like the Join that already exists in System.Linq.Queryable but would generate a Left Join instead of an Inner Join. The current implementation of LeftJoin only accepts a Func<T, bool> and I have no idea how to make that work in fluent syntax.

Note: LoadWith isn’t working properly for me, it still generates “n+1” queries instead of a single join query (even though I’ve seen old closed issues here saying that it’s implemented).

Environment details

linq2db version: 1.10.2 (Core) Database Server: MySQL 5.7.21 Database Provider: MySql.Data 6.10.6 Operating system: Windows 10 Pro Framework version: .NET Core 2.0

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
MaceWinducommented, Apr 27, 2018

fixed by #1088

2reactions
sdanylivcommented, Apr 2, 2018

@hassanselim0, at first we are thinking how to write linq experssion to be closer to sql. So linq queries are supported by default. With fluent syntax there are many possibilities to write expression that can not be converted to real SQL. I’ll check maybe we can support this fluent syntax without additional superfluous calculations.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you perform a left outer join using linq extension ...
For a (left outer) join of a table Bar with a table Foo on Foo.Foo_Id = Bar.Foo_Id in lambda notation: var qry =...
Read more >
LINQ Left Outer Join in C# With Examples
The Left Join or Left Outer Join is a Join in which each data from the first data source is going to be...
Read more >
Perform left outer joins (LINQ in C#)
You can use LINQ to perform a left outer join by calling the DefaultIfEmpty method on the results of a group join. Note....
Read more >
LINQ Left Join | How left join works in LINQ? | Examples
LINQ Left Join is used to return all the records from the left side data source and the matching records from the right...
Read more >
Working With Left Outer Join Using Lambda And LINQ
A LEFT OUTER JOIN is one of the JOIN operations that allows you to specify a join clause.The LEFT JOIN returns all records...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found