Skip to content

sfacosta/XAF_Non-Persistent-Objects-Editing-Demo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XAF - How to implement CRUD operations for Non-Persistent Objects stored remotely

Scenario

This example demonstrates a possible implementation of editable non-persistent objects that represent data stored remotely and separately from the main XAF application database. These non-persistent objects can be created, deleted, and modified. Their changes are persisted in the external storage. The built-in IsNewObject function is used in the Appearance rule criterion. This rule disables the key property editor after an Account object is saved.

Solution

The following NonPersistentObjectSpace members are used in this example.

Non-persistent objects are kept in an object map. In the ObjectsGetting, ObjectGetting, and ObjectByKeyGetting event handlers, non-persistent objects are looked up and added to the object map. In the Reloaded event handler, the object map is cleared. So, subsequent object queries trigger the creation of new non-persistent object instances. In the ObjectReloading event handler, the state of an existing object is reloaded from the storage.

In the CustomCommitChanges event handler, all object changes are processed and passed to the storage.

The NonPersistentObjectSpace/.AutoSetModifiedOnObjectChange property is set to true to automatically mark non-persistent objects as modified when the INotifyPropertyChanged.PropertyChangedevent is raised.

We use a 'List' as storage for Non-Persistent Object data.

Common Components

The following classes are used to provide a common functionality for all non-persistent objects used in the demo.

NonPersistentObjectBase

The abstract base class for all non-persistent objects used in the application. It provides a common implementation of the INotifyPropertyChanged and IObjectSpaceLink interfaces and some convenient protected methods.

TransientNonPersistentObjectAdapter

The adapter for transient (short-living) Non-Persistent business objects. Such objects exist only while their object space is alive. A new adapter instance is created for each non-persistent object space. It subscribes to object space events to manage a subset of object types in a common manner. It also maintains an identity map (ObjectMap) for NonPersistentObjectSpace.

NonPersistentStorageBase

Descendants of this class know how to create object instances and transfer data between objects and the storage. It knows nothing about the adapter. It also uses the identity map to avoid creating duplicated objects.

Files to Review

Documentation

About

How to implement CRUD operations for Non-Persistent Objects stored remotely in eXpressApp Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 76.9%
  • HTML 21.8%
  • Other 1.3%