确定查询表达式是否为 null。
语法
expression IS [ NOT ] NULL
论据
expression
任何有效的查询表达式。 不能是集合、具有集合成员或具有集合类型属性的记录类型。
不否定 EDM。IS NULL 的布尔结果。
返回值
注解
用于 IS NULL
确定外部联接的元素是否为 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
。 在调用提供程序之前,会从客户端引发所有异常:
图案 | 行为 |
---|---|
null IS NULL | 返回 true 。 |
TREAT (NULL AS EntityType) 为 NULL | 返回 true 。 |
TREAT (NULL AS ComplexType) 为 NULL | 引发错误。 |
TREAT (NULL AS RowType) 为 NULL | 引发错误。 |
EntityType IS NULL | 返回 true 或 false 。 |
ComplexType IS NULL | 引发错误。 |
RowType IS NULL | 引发错误。 |
示例:
以下 Entity SQL 查询使用 IS NOT NULL 运算符来确定查询表达式是否不为 null。 查询基于 AdventureWorks 销售模型。 若要编译并运行此查询,请执行以下步骤:
按照作方法中的过程作 :执行返回 StructuralType 结果的查询。
将以下查询作为参数传递给
ExecuteStructuralTypeQuery
方法:
SELECT VALUE product FROM AdventureWorksEntities.Products
AS product WHERE product.Color IS NOT NULL