This project is read-only.


Returns a collection of objects from a query expression that is of a specific type.


OFTYPE (expression, [ONLY] test_type)


expression: Any valid query expression that returns a collection of objects.
test_type: The type to test each object returned by expression against. The type must be qualified by a namespace.

Return Value

A collection of objects that are of type testtype, or a base type or derived type of testtype. If ONLY is specified, only instances of the test_type or an empty collection will be returned.


An OFTYPE expression specifies a type expression that is issued to perform a type test against each element of a collection. The OFTYPE expression produces a new collection of the specified type containing only those elements that were either equivalent to that type or a sub-type of it.
An OFTYPE expression is an abbreviation of the following query expression:
select value treat(t as T) from ts as t where t is of (T)


var esql = "select c from oftype(Contacts, FullContact) as c";
var q = db.CreateQuery<EmployeeContact>(esql);
string esql = "select c from oftype(Contacts, only FullContact) as c";
var q = db.CreateQuery<EmployeeContact>(esql);

Last edited Mar 13, 2013 at 8:26 AM by ansiboy, version 1


No comments yet.