EXCEPT (Entity SQL)

Returns a collection of any distinct values from the query expression to the left of the EXCEPT operand that are not also returned from the query expression to the right of the EXCEPT operand. All expressions must be of the same type or of a common base or derived type as expression.

expression EXCEPT expression

引数

  • expression
    コレクションを返す任意の有効なクエリ式。もう一方のクエリ式から返されたコレクションと比較されます。

戻り値

expression と同じ型であるか、共通の基本データ型または派生型であるコレクション。

解説

EXCEPT は、Entity SQL の集合演算子の 1 つです。 Entity SQL のすべての集合演算子は左から右に評価されます。 次の表に、Entity SQL 集合演算子の優先順位を示します。

優先順位 演算子

最高

INTERSECT

UNION

UNION ALL

EXCEPT

最低

EXISTS

OVERLAPS

FLATTEN

SET

次の Entity SQL クエリでは、EXCEPT 演算子を使用して、2 つのクエリ式から重複しない値のコレクションを返します。 このクエリは、AdventureWorks Sales Model に基づいています。 このクエリをコンパイルして実行するには、次の手順を実行します。

  1. Follow the procedure in StructuralType 結果を返すクエリの実行方法 (EntityClient).

  2. Pass the following query as an argument to the ExecuteStructuralTypeQuery method:

(SELECT product from AdventureWorksEntities.Products as product 
    WHERE product.ListPrice  > @price1 ) except 
    (select product from AdventureWorksEntities.Products as product 
    WHERE product.ListPrice > @price2)

参照

概念

Entity SQL リファレンス