次の方法で共有


|| (OR) (Entity SQL)

2 つの Boolean 式を結合します。

boolean_expression OR boolean_expression
or 
boolean_expression || boolean_expression

引数

  • boolean_expression
    Boolean 値を返す任意の有効な式。

戻り値

いずれかの条件が true の場合は true、それ以外の場合は false

解説

OR は Entity SQL の論理演算子です。 2 つの条件を結合する場合に使用します。 1 つのステートメント内に複数の論理演算子が使われている場合、OR 演算子は AND 演算子の次に評価されます。 ただし、かっこを使うと、演算の順序を変更することができます。

二重の縦棒 (||) は、OR 演算子と同じ効果を持ちます。

使用可能な入力値と戻り値の型を次の表に示します。

TRUE FALSE NULL

TRUE

TRUE

TRUE

TRUE

FALSE

TRUE

FALSE

NULL

NULL

TRUE

NULL

NULL

次の Entity SQL クエリでは、OR 演算子を使用して 2 つの Boolean 式を結合します。 このクエリは、AdventureWorks Sales Model に基づいています。 このクエリをコンパイルして実行するには、次の手順を実行します。

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

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

-- OR
SELECT VALUE product FROM AdventureWorksEntities.Products 
                                    AS product where product.ListPrice = @price1 OR product.ListPrice = @price2
-- || 
SELECT VALUE product FROM AdventureWorksEntities.Products 
                                    AS product where product.ListPrice = @price1 || product.ListPrice = @price2

参照

概念

Entity SQL リファレンス