Left Join in Entity Framework 3.5

I am trying to leave join at the work of entity frame 3.5, but I cannot do this ...

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 the left join instead of joining?

+4
source share
3 answers

You need to use DefaultIfEmpty() for the 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 } 

The appearance of from / select above is not needed, just execute the ta and uf project in what you need.

+1
source

Here you will find examples of various LINQ associations: http://code.msdn.microsoft.com/LINQ-Join-Operators-dabef4e9 and downloads of other LINQ examples.

0
source

The Entity framework in .NET 3.5 does not offer a left join in Linq queries. The way to get "merged records" is a property of navigation between faces

From here: Left external registration in asp.net entity data model

0
source

Source: https://habr.com/ru/post/1385107/


All Articles