Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
The FieldAlias Attribute
Programmer's Guide > OpenAccess ORM Classic (Old API) > Telerik OpenAccess ORM OQL Reference > OQL - Object Query Language > The FieldAlias Attribute

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 FieldAlias attribute marks the property as an alias for a given field. This enables the use of public properties in OQL expressions. Whenever the query parser encounters a property in an OQL query, it uses the corresponding field that has been specified in the FieldAlias attribute. The property is not evaluated during OQL expression evaluation, but the name of the property is replaced with the field name given in the FieldAlias attribute constructor. 

The FieldAlias attribute is added as shown below:

C# Copy Code
class Person {
private string name;

public string Name
 get {
return name; }
 set { name = value; }

After adding the FieldAlias attribute, it is now possible to use the property as an alias for a field in a query:

OQL Copy Code
FROM PersonExtent AS x
WHERE  x.NAME LIKE 'Peter*'"

The FieldAlias attribute is useful when the field is private and it needs to be kept that way. Currently the enhancer does not check if the correct field is being used; it only checks that such a field exists in the class and it is not transient. No property code is executed for the query.