次の方法で共有


IS [NOT] NULL (Entity SQL)

クエリ式が NULL かどうかを調べます。

expression IS [ NOT ] NULL

引数

  • expression
    任意の有効なクエリ式。 コレクションにすることはできません。また、コレクション メンバーや、コレクション型のプロパティを持つレコード型を含めることはできません。
  • NOT
    IS NULL の EDM.Boolean の結果を否定します。

戻り値

expression によって NULL が返される場合は true、それ以外の場合は false です。

解説

外部結合の要素が NULL かどうかを確認するには、IS NULL を使用します。

select c 
      from LOB.Customers as c left outer join LOB.Orders as o 
                              on c.ID = o.CustomerID  
      where o is not null and o.OrderQuantity = @x

メンバーに実際の値が含まれているかどうかを確認するには、IS NULL を使用します。

select c from LOB.Customer as c where c.DOB is not null

次の表は、いくつかのパターンにおける IS NULL の動作を示しています。 All exceptions are thrown from the client side before the provider gets invoked:

パターン 動作

null IS NULL

Returns true.

TREAT (null AS EntityType) IS NULL

Returns true.

TREAT (null AS ComplexType) IS NULL

エラーをスローします。

TREAT (null AS RowType) IS NULL

エラーをスローします。

EntityType IS NULL

Returns true or false.

ComplexType IS NULL

エラーをスローします。

RowType IS NULL

エラーをスローします。

The following Entity SQL query uses the IS NOT NULL operator to determine if a query expression is not null. このクエリは、AdventureWorks Sales Model に基づいています。 このクエリをコンパイルして実行するには、次の手順を実行します。

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

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

SELECT VALUE product FROM AdventureWorksEntities.Products 
    AS product WHERE product.Color IS NOT NULL

参照

概念

Entity SQL リファレンス