Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Transient Attribute
Programmer's Guide > OpenAccess ORM Classic (Old API) > Programming With OpenAccess > Attributes > Field Attributes > Transient 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 [Transient] attribute is used to mark a field of a persistence capable class as a transient field. Transient fields can be used in situations where you want an actual data-member (for performance, as a buffer for an edit control, or other reasons), but the data itself is easily derived from the data already present in the object. You can also use a transient data-member to hold the GUI component that is used to edit the object. Any data that is needed only at runtime and does not need to be persistent (stored with the object) is a candidate for the transient modifier.

In the following example, the age field of the Employee class is transient:

Copy Code
[OpenAccess.Persistent]
class Employee
{
  // . . .
  [OpenAccess.Transient]
  int age; // this is not a persistent field
  // . . .
}

The [Transient] Attribute and Delegate Fields

All fields of a persistence capable class are persistent by default except delegate fields. Fields of type System.Delegate (and types derived from System.Delegate) are only persistent if the field type is a persistence capable class. This special behavior is useful when persistence capable classes contain events. For events the .NET compilers generate an implicit field that contains the delegate used for the event. The [Transient] attribute cannot be applied to this generated field because the generated field is not visible in the source code.

Fields that are not delegates, the [Transient] attribute must be explicitly specified if the referenced class is not persistent.