Skip to main content
.NET 8.0+

XPDelayedProperty Class

A delayed property. The delayed property will be loaded the first time it is accessed.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.2.dll

Declaration

public class XPDelayedProperty

Remarks

By default, all properties and fields are restored from the data store when a persistent object is loaded. For optimization purposes, it’s possible to delay the loading of particular properties such as those that are rarely used or contain large amounts of data. Note that field loading cannot be delayed.

To delay the loading of a property, apply the DelayedAttribute attribute with the specified name of the field which stores the delayed property’s value. Note that the field must be of the XPDelayedProperty type (see the example below).

For more information, see the Delayed Loading concept.

Example

The following example demonstrates how to delay the loading of the DelayedAttachment property and improve property value update performance, by enabling the DelayedAttribute.UpdateModifiedOnly property.

Note

This solution uses the XPDelayedProperty object explicitly and doesn’t raise property change notifications in all scenarios. You may need to explicitly call the Session.Save method after modifying the property value to save changes. Alternatively, implement the delayed property as shown in the Delayed Loading article.

using DevExpress.Xpo;

public class Customer : XPObject {
   // ...
   private XPDelayedProperty document = new XPDelayedProperty();
   // Improve update performance for the property's value
   // by passing true as the attribute's
   // updateModifiedOnly parameter.
   [Delayed(nameof(document), true)]
   public Byte[] DelayedAttachment {
      get { return (Byte[])document.Value; }
      set { document.Value = value; }
   }
}

Inheritance

Object
XPDelayedProperty
See Also