Telerik OpenAccess Classic

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

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.

The IN extent clause allows you to test for the presence of an object in a class extent (classname Extent or its alias). The object being tested must be a referenced object of the set-variable. The IN extent clause is used within the WHERE statement. The clause returns a boolean value, i.e., true or false.

The following example query uses the IN extent clause.

OQL Copy Code
SELECT * FROM ProductExtent AS product WHERE product.supplier IN SupplierExtent

 

This query selects the product if the product supplier is in the SupplierExtent. If all products in the database have a reference to a Suplier object that is in the SuplierExtent, this query returns all products.

Another example of using the IN operator is given below:

C# Copy Code
[Persistent]
class C
{
public string field1;}
[Persistent]
class Ca : C
{
public string field1_a;
public string field2_a;
public string field3_a;
}
[Persistent]
class Cb : C
{
public string field1_b;
}
[Persistent]
class Cc : C
{
string field1_c;
}
[Persistent]
class Cd : C
{
int field1_d;
}  

Now, if we want to return all the instances of A or B, the following query can be used:

OQL Copy Code
SELECT * FROM CExtent AS obj
WHERE (obj IN CaExtent) OR (obj IN CbExtent)

In the above case, both Ca and Cb are derived from C. This query will only match instances of Ca or Cb, since it tests additionally that the instance is only in the Ca or Cb extent; so not even pure C instances are matched.

Using the NOT logical operator together with the IN operator
The NOT operator is used for negating a criteria. Therefore, if you need to find instances that are not part of something, say a collection, you can use the NOT with the IN operator as shown below:

OQL Copy Code
Select * from TerritoryExtent as tr, EmployeeExtent as emp where NOT(tr in emp.employeeTerritories)

The above query will return all the Territories from which there are no employees. 

See Also