Reputation: 6353
I have for simplicity 2 tables:
Table1 has UserId Email
Table2 has UserId Score
I want to filter out all scores > 10. But, Table2 is not guaranteed to have any users in it. UserId is a PK and FK on Table2. UserId is a PK on table 1.
My issue is that I need to get all scores where they exist and then check them.
Upvotes: 0
Views: 62
Reputation: 52675
See Left Outer Join
var q =
from user in Table1
join s in Table2 on user.UserId equals score.UserId into lscore
from score in lscore.DefaultIfEmpty()
where score == null || lscore.score < 10
select new { userId = user.userid, email = user.Email, Score = score == null ? 0 : lscore.score };
Upvotes: 1