Reputation: 2896
I am trying to left join on entity frame work 3.5 but i am unable to do so...
from i in
(from ta in context.test_attempt
join uf in context.user_flag on ta.users.USERID equals uf.UserID)
select i;
I want to use left join instead to join?
Upvotes: 4
Views: 3620
Reputation: 19050
Entity framework in .NET 3.5 doesn't offer left join in Linq queries. The way to get "joined records" is through navigation property between entities
From here: Left Outer Join in Entity Data Model asp.net
Upvotes: 0
Reputation: 99
You will find examples of different LINQ joins here: http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9 and loads of other LINQ examples too.
Upvotes: 0
Reputation: 77520
You need to use DefaultIfEmpty()
for an outer join:
from ta in context.test_attempt
join uf in context.user_flag on ta.users.USERID equals uf.UserID into g
from uf in g.DefaultIfEmpty()
select new { ta, uf }
Your outer from/select above is unnecessary, just project ta
and uf
into what you need.
Upvotes: 1