使用 Intersect 运算符可返回两个序列的交集。
示例:
此示例使用Intersect来返回Customers和Employees同时居住的所有国家/地区的序列。
var infoQuery =
(from cust in db.Customers
select cust.Country)
.Intersect
(from emp in db.Employees
select emp.Country)
;
Dim infoQuery = _
(From cust In db.Customers _
Select cust.Country) _
.Intersect _
(From emp In db.Employees _
Select emp.Country)
在 LINQ to SQL 中,Intersect 操作仅在集上定义明确。 多集的语义未定义。