Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
See Also
Programmer's Guide > OpenAccess ORM Classic (Old API) > Telerik OpenAccess ORM OQL Reference > OQL - Object Query Language > The Select Statement > Extents

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

An extent contains all objects in a database that belong to a specific persistence capable class. This also includes subclass instances, such as, a Lion is a Cat. OQL queries operate on extents, whereas SQL queries use tables. When formulating a query, use the name of the class plus the word Extent to specify the extent name. If, for example, you have a class named Employee, the extent for the class would be called EmployeeExtent.

The following is an example of querying a class named Employee. Note that the AS statement defines the set variable, which is an alias for the extent.

OQL Copy Code
FROM EmployeeExtent AS employee

The statement above returns all Employee objects.

Using the Set-Variable

When you use an extent in a SELECT statement, an explicit extent variable, the set-variable, is associated with the extent. This variable acts as a surrogate name for every element of the extent set, allowing you to specify class members in the WHERE clause and result-set specification of a query.

In the following statement, the objects of the extent are associated with the set-variable customer. By using the variable customer, you can select objects based on the value of a data-member of the class in your query.

OQL Copy Code
FROM CustomerExtent AS customer
WHERE customer.CustomerID = 'ALFKI'

This example selects the object (customer) from the CustomerExtent whose ID is "ALFKI". You can also specify the extent variable in the result-set description (refer to Result Sets topic for more information).

OQL Copy Code
SELECT customer
FROM CustomerExtent AS customer
WHERE customer.CustomerID = 'ALFKI'

This example produces the same result as the previous example. Here is a sample application that executes the query and displays the result:

C# Copy Code
IObjectScope scope =OpenAccessData.ObjectScopeProvider1.GetNewObjectScope();
string query = "SELECT customer FROM CustomerExtent AS customer WHERE customer.CustomerID = 'ALFKI'";
var result = scope.GetOqlQuery(query).Execute();
foreach (OpenAccessData.Customer cst in result)
VB.NET Copy Code
Dim scope As IObjectScope = OpenAccessData.ObjectScopeProvider1.GetNewObjectScope()
Dim query As String = "SELECT customer FROM CustomerExtent AS customer WHERE customer.CustomerID = 'ALFKI'"
Dim result As var = scope.GetOqlQuery(query).Execute()
For Each cst As OpenAccessData.Customer In result

Extent Aliases

An alias name can be defined for an extent; this is useful when type names with namespace qualifiers are needed. Temporary aliases are defined directly in OQL using the DEFINE EXTENT statement.

In the following example, an extent alias named emp is defined for the class Employee:

OQL Copy Code

This example defines an alias for the EmployeeExtent.

The alias, emp, can then be used in subsequent OQL statements, instead of the default EmployeeExtent. The following statement selects all Employee objects.

OQL Copy Code
FROM emp

The DEFINE EXTENT statement is optional. It is most useful for creating temporary shorthand aliases for extents.

See Also