| 運算子 | 行為 | 去重複 |
|---|---|---|
| Concat | 連接兩序列,保留所有元素 | 否 |
| Union | 合併兩序列,移除重複 | 是 |
| Intersect | 取兩序列交集 | 是 |
| Except | 第一序列減去第二序列 | 是 |
皆為延遲執行。
var q = (from c in db.Customers select c.Phone)
.Concat(from c in db.Customers select c.Fax)
.Concat(from e in db.Employees select e.HomePhone);
var q = (from c in db.Customers select new { Name = c.CompanyName, c.Phone })
.Concat(from e in db.Employees select new { Name = e.FirstName + " " + e.LastName, Phone = e.HomePhone });
var q = (from c in db.Customers select c.Country)
.Union(from e in db.Employees select e.Country);
var q = (from c in db.Customers select c.Country)
.Intersect(from e in db.Employees select e.Country);
var q = (from c in db.Customers select c.Country)
.Except(from e in db.Employees select e.Country);