Except使用運算符可傳回兩個序列之間的集合差異。
範例
此範例會使用 Except 傳回一個序列,其中包含 Customers 居住的所有國家/地區,但沒有 Employees 居住的地方。
var infoQuery =
(from cust in db.Customers
select cust.Country)
.Except
(from emp in db.Employees
select emp.Country)
;
Dim infoQuery = _
(From cust In db.Customers _
Select cust.Country) _
.Except _
(From emp In db.Employees _
Select emp.Country)
在 LINQ to SQL 中,Except 操作只能在集合上明確定義。 未定義多重集的語意。