I found this code at LINQ - Full Outer Join:
var leftOuterJoin = from first in firstNames
join last in lastNames
on first.ID equals last.ID
into temp
from last in temp.DefaultIfEmpty(new { first.ID, Name = default(string) })
select new
{
first.ID,
FirstName = first.Name,
LastName = last.Name,
};
var rightOuterJoin = from last in lastNames
join first in firstNames
on last.ID equals first.ID
into temp
from first in temp.DefaultIfEmpty(new { last.ID, Name = default(string) })
select new
{
last.ID,
FirstName = first.Name,
LastName = last.Name,
};
The answer containing this code got a lot of upvotes but I am observing something wrong here. In left outer join it uses into
and from
with second entity, in right outer join it does the same. So, both implementations seem the same to me. Can you tell me the difference between left outer join and right outer join? Thanks in advance.
EDIT :
I think right outer join should be like this :
var rightOuterJoin = from first in firstNames
join last in lastNames
on first.ID equals last.ID
into temp
from first in temp.DefaultIfEmpty(new { last.ID, Name = default(string) })
select new
{
last.ID,
FirstName = first.Name,
LastName = last.Name,
};