Posted By

housecor on 01/20/11


Tagged


Versions (?)

LINQ not in statement


 / Published in: C#
 

URL: http://stackoverflow.com/questions/183791/how-would-you-do-a-not-in-query-with-linq

Note that .Except is a great option too, but only if you're dealing with a list of value types (it doesn't work with complex types unless you implement an iEqualityOperator)

  1. from c in dc.Customers
  2. where !(from o in dc.Orders
  3. select o.CustomerID)
  4. .Contains(c.CustomerID)
  5. select c;

Report this snippet  

You need to login to post a comment.