I have two tables. One user table and one table in which results are placed of a certain test.
When a user takes a test his result and his user_id are placed in the results table. When a user never took a test then obviously his user_id won’t be in the results table.
I need to get all the users that are NOT in the results table. Is there a way to do this in one query? (Entity Framework)
Getting all the users is easy. But now i need a way to link it to the results table to see which of the users i want in my result set.
(from u in entity.Users
[where not in results table..??]
select u);
Fully working example, using mock objects:
.DefaultIfEmpty() is what you are after – if it brings back an empty result you have an object in table A that does not show in table B.