ISOF (Entity SQL)

Determines whether the type of an expression is of the specified type or one of its subtypes.


expression IS [ NOT ] OF ( [ ONLY ] type )  


Any valid query expression to determine the type of.

Negates the EDM.Boolean result of IS OF.

Specifies that IS OF returns true only if expression is of type type and not any of one its subtypes.

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.


The expressions expression IS NOT OF (type) and expression IS NOT OF (ONLY type) are syntactically equivalent to NOT (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


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)

See Also

Entity SQL Reference