Linq not contains dynamic query
14,589
Solution 1
just use !
before the contains condition. Like
var myProducts = from p in products
where !productList.Contains(p.ID)
select p;
Solution 2
Some thing like this should help...
YourDataContext dc = new YourDataContext();
var query =
from c in dc.Customers
where !(from o in dc.Orders
select o.CustomerID)
.Contains(c.CustomerID)
select c;
Solution 3
Use !
operator. Like this:
private List<int> iList = new List<int>
{
1,2,3,4,5,6,7,8,9
};
if (!iList.Contains(888))
{
}
Author by
Serhat Koroglu
Updated on June 26, 2022Comments
-
Serhat Koroglu almost 2 years
Possible Duplicate:
Linq to SQL “not like” operatorHow can I write a dynamic linq query with using not contains?
I use
.Contains()
instead of like. But what should I use instead ofnot like
?