0

I would like to convert this sql query to linq:

SELECT Number
FROM Pager 
FULL OUTER JOIN Location
ON Pager.PagerId = Location.PagerId
FULL OUTER JOIN PersonCalls
ON Pager.PagerId = PersonCalls.PagerId
FULL OUTER JOIN Activity
ON Pager.PagerId = Activity.PagerId
WHERE (Pager.PagerId IS NULL OR Location.PagerId IS NULL) AND
(Pager.PagerId IS NULL OR PersonCalls.PagerId IS NULL) AND
(Pager.PagerId IS NULL OR Activity.PagerId IS NULL)

this works correctly. but for linq I tested this code:

var query = from Activity in db.Activity
 from Location in db.Location
from PersonCalls in db.PersonCalls
where
(Activity.Pager.PagerId == null ||
Location.PagerId == null) &&
 (Activity.Pager.PagerId == null ||
PersonCalls.PagerId == null) &&
(Activity.Pager.PagerId == null ||
Activity.PagerId == null)
select new {
 Activity.Pager.Number
}

that give me no result!

amir stack
  • 217
  • 1
  • 12
  • 1
    LINQ does not provide a **full** join. It combines only _exisiting_ elements. So in your linq expression, _all existing_ activities are combined with _all existing_ locations and the combinations are combined with _all existing_ calls. Btw: you miss the matching of the `PagerId`s in that expression. – René Vogt Feb 22 '17 at 11:23
  • 1
    LEFT OUTER JOIN is same as LEFT JOIN This might help: http://stackoverflow.com/questions/4497086/linq-left-join-and-right-join – Netferret Feb 22 '17 at 14:09

0 Answers0