Skip to main content
A newer version of this page is available. .

Delayed Loading

  • 2 minutes to read

Persistent properties mapped to columns that contain large amounts of data (images, large text documents, or binary data) require a lot of memory. Decorate such properties with the DelayedAttribute to enable delayed loading. XPO does not populate such properties until you call the GetDelayedPropertyValue method.

[Delayed(true)]
public Byte[] BigPicture {
    get { return GetDelayedPropertyValue<Byte[]>(nameof(BigPicture)); }
    set { SetDelayedPropertyValue<Byte[]>(nameof(BigPicture), value); }
}

The DelayedAttribute.UpdateModifiedOnly property specifies whether to include delayed properties in UPDATE statements. Set this property to true (Delayed(true)) to reduce the amount of data transferred between your application and the database server.

If you have multiple delayed properties in a persistent class, use the DelayedAttribute.GroupName property to arrange delayed properties in groups. When you read a property that belongs to a group, XPO loads all properties in the same group simultaneously.

Note

  • If a property type is a persistent class, the GroupName property is not taken into account and these properties are loaded separately.
  • Persistent members declared as fields do not support delayed loading.
  • Do not use the DelayedAttribute with collection properties. XPO always loads collection properties on demand.