Back to Devexpress

PersistentBase Class

xpo-devexpress-dot-xpo-634dafd5.md

latest6.3 KB
Original Source

PersistentBase Class

Serves as a base for classes that represent persistent objects.

Namespace : DevExpress.Xpo

Assembly : DevExpress.Xpo.v25.2.dll

NuGet Package : DevExpress.Xpo

Declaration

csharp
[NonPersistent]
[MemberDesignTimeVisibility(false)]
[OptimisticLocking(true)]
public class PersistentBase :
    IXPObject,
    IXPSimpleObject,
    IXPClassInfoAndSessionProvider,
    IXPClassInfoProvider,
    IXPDictionaryProvider,
    ISessionProvider,
    IObjectLayerProvider,
    IDataLayerProvider,
    IXPCustomPropertyStore,
    IXPModificationsStore,
    IXPInvalidateableObject,
    IXPReceiveOnChangedFromDelayedProperty,
    IXPReceiveOnChangedFromArbitrarySource,
    INotifyPropertyChanged,
    IXPImmutableHashCode
vb
<NonPersistent>
<MemberDesignTimeVisibility(False)>
<OptimisticLocking(True)>
Public Class PersistentBase
    Implements 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.

csharp
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); }
    }
}
vb
Imports System.ComponentModel
Imports DevExpress.Xpo

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

Public Class [MyClass]
    Inherits PersistentBase
    Public Sub New(ByVal session As Session)
        MyBase.New(session)
    End Sub
    ' PersistentBase does not have a built-in key and you need to add your own key
    <Key(AutoGenerate:=True)>
    <Browsable(False)>
    Public Property Oid() As Integer
    Private fMyProperty As String
    Public Property MyProperty() As String
        Get
            Return fMyProperty
        End Get
        Set(ByVal value As String)
            SetPropertyValue(NameOf(MyProperty), fMyProperty, value)
        End Set
    End Property
End Class

Implements

IXPObject

IXPSimpleObject

ISessionProvider

IXPModificationsStore

Inheritance

Show 17 items

Object PersistentBase XPBaseObject

XPCustomObject

XPDataObject

XPLiteObject

XPObject

XPWeakReference

BaseObject

DashboardData

ReportDataV2

MediaDataObject

ModelDifference

ModelDifferenceAspect

PermissionPolicyRole

PermissionPolicyRoleBase

PermissionPolicyUser

Inheritance

Object PersistentBase XPBaseObject

XPCustomObject

XPDataObject

XPLiteObject

XPObject

XPWeakReference

See Also

PersistentBase Members

XPO Classes Comparison

DevExpress.Xpo Namespace