/XAF-How-to-Implement-CRUD-Operations-for-Non-Persistent-Objects-Stored-Remotely

How to implement CRUD operations for remotely stored non-persistent objects in XAF applications.

Primary LanguageC#OtherNOASSERTION

XAF - How to Implement CRUD Operations for Non-Persistent Objects Stored Remotely

This example demonstrates an implementation of editable non-persistent objects that represent data stored remotely and separately from the main XAF application database. You can create, modify, and delete these non-persistent objects. The changes are persisted in the external storage. The built-in IsNewObject function is used in the Appearance rule criterion that disables the key property editor after a non-persistent object is saved.

Implementation Details

This example uses NonPersistentObjectSpace members.

Non-persistent objects are kept in an object map. XAF uses event handlers to manage these objects.

  1. To look up non-persistent objects and add them to the object map:

  2. To clear the object map:

    • Reloaded

      Subsequent object queries trigger the creation of new non-persistent object instances.

  3. To reload the state of an existing object from storage:

  4. To process all object changes and pass them to storage:

The NonPersistentObjectSpace.AutoSetModifiedOnObjectChange property is set to true to automatically mark non-persistent objects as modified when XAF raises the INotifyPropertyChanged.PropertyChanged event.

List<T> objects store non-persistent data.

Common Components

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

  • TransientNonPersistentObjectAdapter
    The adapter for transient (short-living) non-persistent business objects. Such objects exist only during the lifespan of their object space. 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. They know nothing about the adapter. They also use the identity map to avoid creating duplicated objects.

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)