xpo-devexpress-dot-xpo-eb85656f.md
Implements the IXPObject and provides a custom key definition.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[NonPersistent]
[MemberDesignTimeVisibility(false)]
[DeferredDeletion]
public abstract class XPCustomObject :
XPBaseObject
<NonPersistent>
<MemberDesignTimeVisibility(False)>
<DeferredDeletion>
Public MustInherit Class XPCustomObject
Inherits XPBaseObject
When creating a persistent object by deriving from the 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 : XPCustomObject {
public MyClass(Session session) : base(session) { }
// XPCustomObject 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); }
}
}
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 XPCustomObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
' XPCustomObject 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
Show 15 items
Object PersistentBase XPBaseObject XPCustomObject XPObject
Object PersistentBase XPBaseObject XPCustomObject XPObject
See Also