TREAT

Treats an object of a particular base type as an object of the specified derived type.

Syntax

TREAT (expression as type)

Arguments

expression: Any valid query expression that returns an entity.
type: An entity type.

Remarks

TREAT is used to perform upcasting between related classes. For example, if Employee derives from Person and p is of type Person, TREAT(p AS NamespaceName.Employee) upcasts a generic Person instance to Employee; that is, it allows you to treat p as Employee.

TREAT is used in inheritance scenarios where you can do a query like the following:
SELECT TREAT(p AS Employee)
FROM ContainerName.Person AS p
WHERE p IS OF (Employee)

Last edited Mar 12, 2013 at 9:08 AM by ansiboy, version 1

Comments

No comments yet.