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 Refresh Action.
When implementing the IObjectSpace interface in the BaseObjectSpace class's descendant, override a protected virtual BaseObjectSpace.Reload method. It is invoked by the BaseObjectSpace.Refresh method, which does the following: If none of objects belonging to the current Object Space have been changed after retrieving them or after the last commit (see IObjectSpace.CommitChanges), the BaseObjectSpace.Refresh method recreates the Object Space's container for in-memory objects by calling the Reload method, re-retrieves the objects from it and returns true. If at least one object change has been performed, the IObjectSpace.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 IObjectSpace.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.
The BaseObjectSpace.Reload method is invoked to recreate the Object Space's container for in-memory objects (XPObjectSpace.Session in XPObjectSpace and EFObjectSpace.ObjectContext in EFObjectSpace), and persistent objects are re-retrieved. The BaseObjectSpace.Refresh method returns true.
The BaseObjectSpace.Refresh method does nothing and returns false.
The IObjectSpace.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 again retrieves objects via a reestablished database connection.
The following events related to the Refresh method are available:
Raised before the refresh to prevent it.
Rasied before the refresh to force a custom refresh operation instead of the default one.
So, to implement a refresh operation, you have to only override the BaseObjectSpace.Reload method. In this method, recreate the Object Space's container for in-memory objects (in XPO it's a XPObjectSpace.Session, in the Entity Framework it's EFObjectSpace.ObjectContext).