Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Determines whether the type of an expression is of the specified type or one of its subtypes.
expression IS [ NOT ] OF ( [ ONLY ] type )
Arguments
- expression
Any valid query expression to determine the type of.
- NOT
Negates the EDM.Boolean result of IS OF.
- ONLY
Specifies that IS OF returns true only if expression is of type type and not any of one its subtypes.
- type
The type to test expression against. The type must be namespace-qualified.
Return Value
true if expression is of type T and T is either a base type, or a derived type of type; null if expression is null at runtime; otherwise, false.
Remarks
The expressionsexpression IS NOT OF (type)
andexpression IS NOT OF (ONLY type)
are syntactically equivalent toNOT (expression IS OF (type))
and NOT (expression IS OF (ONLY type))
, respectively.
The following table shows the behavior of IS OF operator over some typical- and corner patterns. All exceptions are thrown from the client side before the provider gets invoked:
Pattern | Behavior |
---|---|
null IS OF (EntityType) |
Throws |
null IS OF (ComplexType) |
Throws |
null IS OF (RowType) |
Throws |
TREAT (null AS EntityType) IS OF (EntityType) |
Returns DBNull |
TREAT (null AS ComplexType) IS OF (ComplexType) |
Throws |
TREAT (null AS RowType) IS OF (RowType) |
Throws |
EntityType IS OF (EntityType) |
Returns true/false |
ComplexType IS OF (ComplexType) |
Throws |
RowType IS OF (RowType) |
Throws |
Example
The following Entity SQL query uses the IS OF operator to determine the type of a query expression, and then uses the TREAT operator to convert an object of the type Course to a collection of objects of the type OnsiteCourse. The query is based on the School Model.
SELECT VALUE TREAT (course as SchoolModel.OnsiteCourse)
FROM SchoolEntities.Courses as course
WHERE course IS OF( SchoolModel.OnsiteCourse)