Navigation Menu

Skip to content

DevExpress-Examples/XAF_Non-Persistent-Objects-Reloading-Demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XAF - How to refresh non-persistent objects and reload nested persistent objects

It is often necessary to undo changes made to non-persistent objects in a view. If a non-persistent object has links to persistent objects, it is often required to reload these linked objects as well. However, by default, the built-in Refresh action has no effect in these scenarios. This example shows how to refresh data in such cases.

devenv_8Nt2WqQLBv

Warning

We created this example for demonstration purposes and it is not intended to address all possible usage scenarios. If this example does not have certain functionality or you want to change its behavior, you can extend this example. This can be a complex task that requires good knowledge of XAF: UI Customization Categories by Skill Level, and you may need to research how our components work. Refer to the following help topic for more information: Debug DevExpress .NET Source Code with PDB Symbols. We are unable to help with such tasks as custom programming is outside our Support Service scope: Technical Support Scope.

Implementation Details

To restore a previous non-persistent object state, that state should be kept separately. In this example, data for non-persistent objects is stored in a static collection, and object instances are populated with this data when they are created and reloaded.

  1. Create an object map for each NonPersistentObjectSpace to keep non-persistent object instances separate. The ObjectsGetting, ObjectGetting, and ObjectByKeyGetting event handlers look for non-persistent objects and add them to the object map. The Reloaded event handler clears the object map. Subsequent object queries trigger the creation of new non-persistent object instances that are populated with data from storage.
  2. Set the NonPersistentObjectSpace.AutoReloadAdditionalObjectSpaces property to true to automatically refresh persistent object spaces added to the NonPersistentObjectSpace.AdditionalObjectSpaces collection. So, when non-persistent objects are re-created on refresh, they get fresh copies of nested persistent objects.
  3. Set the NonPersistentObjectSpace.AutoDisposeAdditionalObjectSpaces property to true to automatically dispose of additional object spaces when the non-persistent object space is disposed of. You should dispose of unused object spaces to avoid memory leaks.
  4. The non-persistent LiveSummary object in this example contains a collection of persistent objects and some derived properties calculated from persistent objects that match parameters. After modifying persistent objects, use the built-in Refresh action to reload non-persistent object views.

Files to Review

Documentation

More Examples

Releases

No releases published

Packages

No packages published

Languages

  • C# 75.5%
  • HTML 23.4%
  • CSS 1.1%