Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
FieldAlias Attribute
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Attributes > Field Attributes > 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:

Copy Code
class Person {
  private string name;
Copy Code
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:

Copy Code
...GetOqlQuery("SELECT * FROM PersonExtent AS x
     WHERE x.Name LIKE 'Peter*'").Execute();

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.

In case of reverse engineering an existing schema, OpenAccess ORM will automatically add the FieldAlias attribute in the generated code.