How to perform a select using a WHERE NOT EXISTS
- by Peter Bridger
I'm using LINQ2SQL and I want to compare two tables and select all rows that are missing from one tables (based upon one of the column values).
In standard SQL I would write this as:
SELECT
FirstName,
LastName,
RefId,
Email
FROM
Users_ActiveDirectory AS ADU
WHERE
NOT EXISTS
(
SELECT
U.RefId
FROM
Users AS U
WHERE
U.RefID = ADU.RefId
)
However I'm not sure how to achieve the same result using LINQ2SQL?