LINQ to Entity, joining on NOT IN tables

Posted by SlackerCoder on Stack Overflow See other posts from Stack Overflow or by SlackerCoder
Published on 2010-04-06T18:38:29Z Indexed on 2010/04/06 18:43 UTC
Read the original article Hit count: 254

Filed under:
|

My brain seems to be mush right now! I am using LINQ to Entity, and I need to get some data from one table that does NOT exist in another table.

For example: I need the groupID, groupname and groupnumber from TABLE A where they do not exist in TABLE B. The groupID will exist in TABLE B, along with other relevant information. The tables do not have any relationship. In SQL it would be quite simply (there is a more elegant and efficient solution, but I want to paint a picture of what I need)

SELECT GroupID, GroupName, GroupNumber, FROM TableA WHERE GroupID NOT IN (SELECT GroupID FROM TableB)

Is there an easy/elegant way to do this? Right now I have a bunch of queries hitting the db, then comparing, etc. It's pretty messy.

Thanks.

© Stack Overflow or respective owner

Related posts about linq-to-entities

Related posts about sql