Skip to main content
.NET Framework 4.5.2+

BaseObjectSpace.Refresh() Method

Updates the persistent objects belonging to the current Object Space.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public bool Refresh()

Returns

Type Description
Boolean

true if persistent objects were refreshed; otherwise, false.

Remarks

Use this method to update the current Object Space’s persistent objects. For example, this method is used by the built-in RefreshController.RefreshAction Action.

If none of the objects belonging to the current Object Space have been changed after retrieving them or after the last commit (see BaseObjectSpace.CommitChanges), the Refresh method recreates the object that it uses for interacting with data in the form of persistent objects. Thus, the persistent objects retrieved by the current Object Space are refreshed. The Refresh method returns true if the refreshwas performed successfully.

If at least one object change has been performed after retrieval or the last commit, the BaseObjectSpace.ConfirmationRequired event is raised. Handle this event to show a confirmation window that asks whether to save changes. For this purpose, use the XafApplication.AskConfirmation method. This method returns the ConfirmationResult enumeration value that corresponds to an end-user’s choice. Successive actions depend on this choice:

  • Yes

    The BaseObjectSpace.CommitChanges method is invoked. This method saves all the tracked changes made to the Object Space’s persistent objects to the database. The Refresh method returns true.

  • No

    A new object that the Object Space uses for interacting with data in the form of persistent objects is created, and persistent objects are retrieved from the database via this new object. The Refresh method returns true.

  • Cancel

    The Refresh method does nothing and returns false.

The BaseObjectSpace.ConfirmationRequired event is handled only by the WinModificationsController, which is activated for Detail Views in Windows Forms applications. The Controller’s handler invokes a confirmation window as described above. When the Refresh method is invoked within a List View or in an ASP.NET Web Forms application, a confirmation window is not invoked. However, the ConfirmationResult.No value is set by default, which disposes of all changes and retrieves objects.

The following events related to the Refresh method are available:

  • BaseObjectSpace.Refreshing

    Handle this event to prevent refreshing performed by the Refresh method. For this purpose, set the handler’s CancelEventArgs.Cancel parameter to true.

  • BaseObjectSpace.CustomRefresh

    Handle this event to perform a custom refresh instead of the default one. Set the handler’s CompletedEventArgs.Handled parameter to true, to indicate that the refreshing operation has already been performed. Set the handler’s CompletedEventArgs.IsCompleted parameter to the value which will be returned by the Refresh method.

Implements

See Also