Read the solution here:
- http://programminglinq.com/blogs/marcorusso/archive/2008/01/14/the-not-in-clause-in-linq-to-sql.aspx
A quick sample from me:
var orphans = (from c in context.Instances
orderby c.Title
where !(from o in context.CategoryInstances
select o.InstanceID)
.Contains(c.InstanceID)
select c).Skip(PageIndex * PageSize).Take(PageSize);
Essentially, the query does the same thing in C# - that is, to get the list of IDs to check within and then check within it for the ID which is hoping to be not found. Because the whole thing is compiled into SQL before before executed, LINQ generates a NOT EXISTS statement in the WHERE clause, rather than the slower NOT IN.
gracias pa me fue de mucha utilizad
ReplyDelete