Join with Where Clause in LINQ

I've got two tables that I'm trying to join together with an ID, but only select rows from Table A, where a value in Table B is null.

I tried this:

var dbXMLSoccerTeams = (from dbXMLSoccerTeam in data.EFXMLSoccerTeam
     where dbXMLSoccerTeam.ID == (from dbMatchTeam in data.EFMatchingTeamIDs
         where dbMatchTeam.SmarketsID == null
         select dbMatchTeam.XMLSoccerID)
     select dbXMLSoccerTeam);

But I get an error saying that operator == can not be used to compare int to iQueryable int

Jon Skeet
people
quotationmark

It seems to me that you should actually use a join:

var dbXMLSoccerTeams = from dbXMLSoccerTeam in data.EFXMLSoccerTeam
                       join dbMatchTeam in data.EFMatchingTeamIDs
                         on dbXMLSoccerTeam.ID equals dbMatchTeam.XMLSoccerID
                       where dbMatchTeam.SmarketsID == null
                       select dbXMLSoccerTeam;

people

See more on this question at Stackoverflow