This gives you a list of memberless clubs:
from c in db.Clubs where !db.Members.Any( m => m.ClubId == c.Id) select c;
But I suspect that the right way to do this would be to have many, many relationships with the staging table. (Can your data be an exception?) If you belong to 3 Clubs, will you have your entry in the membership table 3 times? You should if ClubId is in the Members table. Change of address should be done for 3 entries. This is not the right way.
Therefore, removing ClubId from the Members table and adding the Members_Clubs table using only MemberId and ClubId will allow you to associate one member with many clubs.
Then the statement will look like this:
from c in db.Clubs where !db.Members_Clubs.Any( mc => mc.ClubId == c.Id) select c;
In this, none of them is βparentβ or βchildβ. This makes them associative objects.
source share