.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PersistentBase Class

Serves as a base for classes that represent persistent objects.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v21.2.dll

Declaration

[NonPersistent]
[MemberDesignTimeVisibility(false)]
[OptimisticLocking(true)]
public class PersistentBase :
    IXPObject,
    IXPSimpleObject,
    IXPClassInfoAndSessionProvider,
    IXPClassInfoProvider,
    IXPDictionaryProvider,
    ISessionProvider,
    IObjectLayerProvider,
    IDataLayerProvider,
    IXPCustomPropertyStore,
    IXPModificationsStore,
    IXPInvalidateableObject,
    IXPReceiveOnChangedFromDelayedProperty,
    IXPReceiveOnChangedFromArbitrarySource,
    INotifyPropertyChanged,
    IXPImmutableHashCode

Remarks

The PersistentBase class provides the basic functionality required by persistent objects. It automatically supports the optimistic concurrency feature. If this feature is not required, you can use the XPLiteObject class instead.

When creating a persistent object by deriving from the PersistentBase, XPBaseObject, XPCustomObject or XPObject class, an OptimisticLockingAttribute is automatically applied to it. This attribute specifies whether a session can lock a persistent object’s state (allows optimistic locking to be enabled).

For more information, see XPObject and Optimistic Concurrency.

The following code demonstrates how to declare a persistent object.

using DevExpress.Xpo;
using System.ComponentModel;

// Other base classes: https://docs.devexpress.com/eXpressAppFramework/113146/concepts/business-model-design/business-model-design-with-xpo/base-persistent-classes

public class MyClass : PersistentBase {
    public MyClass(Session session) : base(session) { }
    // PersistentBase does not have a built-in key and you need to add your own key
    [Key(AutoGenerate = true), Browsable(false)]
    public int Oid { get; set; }
    string fMyProperty;
    public string MyProperty {
        get { return fMyProperty; }
        set { SetPropertyValue(nameof(fMyProperty), ref fMyProperty, value); }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the PersistentBase class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also