2012-07-25 92 views

回答

7

只是在包含條件之前使用!。像

var myProducts = from p in products 
        where !productList.Contains(p.ID) 
        select p; 
+0

我只是把標記放在錯誤的地方。感謝@habib – 2012-07-25 11:36:27

2

一些像這樣的東西應該幫助...

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; 
1

使用!運營商。像這樣:

private List<int> iList = new List<int> 
      { 
       1,2,3,4,5,6,7,8,9 
      }; 

    if (!iList.Contains(888)) 
       { 

       }