Back to Devexpress

How to: Prevent Changes in a Persistent Object from being Automatically Committed

xpo-2060-crud-transactions-how-to-prevent-changes-in-a-persistent-object-from-being-automatically-committed.md

latest1.3 KB
Original Source

How to: Prevent Changes in a Persistent Object from being Automatically Committed

  • Aug 24, 2020

To prevent changes in a persistent object from being automatically committed to a database after you have finished editing its properties in a control bound to the object, override the default IEditableObject interface implementation as shown in the following code example.

csharp
public class PersistentClass: XPCustomObject {
    protected override void BeginEdit() { }
    protected override void EndEdit() { }
    protected override void CancelEdit() { }
}
vb
Public Class PersistentClass : Inherits XPCustomObject
    Protected Overrides Sub BeginEdit()
    End Sub
    Protected Overrides Sub EndEdit()
    End Sub
    Protected Overrides Sub CancelEdit()
    End Sub
End Class

Set the static XPBaseObject.AutoSaveOnEndEdit field to false to prevent the automatic saving of object changes, without having to override the default IEditableObject.EndEdit() method implementation.

See Also

How to: Control Automatic Saving of Objects when Editing in a Grid