IObjectSpace.Rollback(Boolean) Method
Cancels the changes made to the persistent objects belonging to the current Object Space.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v25.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Optional Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| askConfirmation | Boolean | True |
|
Returns
| Type | Description |
|---|---|
| Boolean |
|
Remarks
Use this method to cancel the changes to the current Object Space’s persistent objects. For example, the built-in Cancel Action uses this method.
When you implement the IObjectSpace interface in a descendant of the BaseObjectSpace class, you override the protected virtual BaseObjectSpace.Reload method. The BaseObjectSpace.Rollback method calls Reload.
This method checks if no objects in the current object space change after retrieval or after the last commit (see IObjectSpace.CommitChanges). When there are no changes, BaseObjectSpace.Rollback recreates the container for in-memory objects by calling Reload, retrieves the objects, and returns true.
If at least one object changes, the IObjectSpace.ConfirmationRequired event occurs. Handle this event to show a confirmation window and ask whether to cancel changes. Use the XafApplication.AskConfirmation method to display the confirmation dialog. The method returns a ConfirmationResult enumeration value based on the user’s choice. Your next action depends on this result.
Yes
The
BaseObjectSpace.Reloadmethod recreates the Object Space’s container for in-memory objects. In XPObjectSpace, it uses XPObjectSpace.Session. In EFCoreObjectSpace, it uses EFCoreObjectSpace.DbContext. Then, the object retrieves persistent objects from the database. TheBaseObjectSpace.Rollbackmethod returnstrue.No
The
BaseObjectSpace.Rollbackmethod does nothing and returnsfalse.Cancel
The
Rollbackmethod does nothing and returnsfalse.
The WinModificationsController handles the IObjectSpace.ConfirmationRequired event. This controller activates only for Detail Views in Windows Forms applications. The controller shows a confirmation window as described above. The system does not show a confirmation window when you invoke the Rollback method in a List View. However, it sets the ConfirmationResult.Yes value by default. This action rolls back all changes and retrieves objects using a new Session.
The following events related to the Rollback method are available:
-
Raised before the rollback to prevent it.
-
Raised before the rollback to perform a custom rollback instead of the default one.
To implement a rollback operation, override the BaseObjectSpace.Reload method. In this method, recreate the container for in-memory objects. In XPO, use the XPObjectSpace.Session. In Entity Framework Core, use the EFCoreObjectSpace.DbContext.
The Rollback method includes an optional parameter, askConfirmation = true. If you call the Rollback method without parameters, the method displays the following dialog:

To roll back an Object Space without a confirmation dialog, explicitly set the askConfirmation parameter to false.