Back to Devexpress

DelayedAttribute.UpdateModifiedOnly Property

xpo-devexpress-dot-xpo-dot-delayedattribute.md

latest3.4 KB
Original Source

DelayedAttribute.UpdateModifiedOnly Property

Gets whether the delayed property stores all or only modified values to a data store.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
public bool UpdateModifiedOnly { get; }
vb
Public ReadOnly Property UpdateModifiedOnly As Boolean

Property Value

TypeDescription
Boolean

true if the delayed property’s value is sent to a data store for update only after it has been modified; otherwise, false.

|

Remarks

By default, when a persistent object is saved to a data store, all properties (including delayed properties) send their values for update, regardless of whether or not they have been modified. For delayed properties, you can ensure that only modified property values are saved. To accomplish this, pass true as the delayed attribute’s DelayedAttribute.UpdateModifiedOnly parameter. After this, the delayed property’s value is saved only if the XPDelayedProperty.IsModified property returns true.

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.

csharp
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; }
   }
}
vb
Imports DevExpress.Xpo

Public Class Customer
   Inherits XPObject
   ' ...
   Private document As XPDelayedProperty = New XPDelayedProperty()
   ' Improve update performance for the property's value
   ' by passing true as the attribute's
   ' updateModifiedOnly parameter.
   <Delayed(NameOf(document), True)> _
   Public Property DelayedAttachment() As Byte
       Get
           Return document.Value
       End Get
       Set
           document.Value = value
       End Set
   End Property
End Class

See Also

DelayedAttribute Class

DelayedAttribute Members

DevExpress.Xpo Namespace