LINQ: Implement NOT IN tables with LINQ to Entity

In SQL so many times we need to filter value from one table when the values are not exist on other table.
As Below

SELECT
   GroupID
,

   GroupName
,

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

You can do it as below:


return from c in context.TableA
where !db.context.TableB.Any(p => p.GroupID== c.GroupID)
select c;

Comments

Popular posts from this blog

LINQ: Using int.TryParse() within a LINQ where clause

ASP.Net MVC: Configuring asp.net session state in SQL Server.

IIS: Publish Project to remote IIS with Web Deploy.