Updates the persistent objects belonging to the current Object Space.
true if persistent objects were refreshed; otherwise, false.
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:
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.
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.
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 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:
Handle this event to prevent refreshing performed by the Refresh method. For this purpose, set the handler’s CancelEventArgs.Cancel parameter to true.
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.