|| (OR) (Entity SQL)

結合兩個 Boolean 運算式。

boolean_expression OR boolean_expression
or 
boolean_expression || boolean_expression

Arguments

  • boolean_expression
    傳回 Boolean 的任何有效運算式。

傳回值

當其中一個條件為 true 時就會傳回 true,否則會傳回 false

備註

OR 是 Entity SQL 邏輯運算子, 它是用來結合兩個條件。 當在陳述式中使用一個以上的邏輯運算子時,OR 運算子會在 AND 運算子之後評估。 然而,您可以使用括號來變更評估的順序。

雙分隔號 (||) 的功能與 OR 運算子相同。

以下資料表顯示可能的輸入值和傳回型別。

TRUE FALSE NULL

TRUE

TRUE

TRUE

TRUE

FALSE

TRUE

FALSE

NULL

NULL

TRUE

NULL

NULL

範例

下列 Entity SQL 查詢會使用 OR 運算子結合兩個 Boolean 運算式。 此查詢是根據 AdventureWorks Sales Model。 若要編譯及執行此查詢,請遵循以下步驟:

  1. 按照 HOW TO:執行可傳回 StructuralType 結果的查詢 (EntityClient) 中的程序進行。

  2. 將下列查詢當成引數傳遞至 ExecuteStructuralTypeQuery 方法:

-- 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 參考