xpo-devexpress-dot-xpo-fb1f012c.md
Implements the IXPObject and provides an autogenerated integer key mapped to the ‘OID’ field.
Namespace : DevExpress.Xpo
Assembly : DevExpress.Xpo.v25.2.dll
NuGet Package : DevExpress.Xpo
[NonPersistent]
[MemberDesignTimeVisibility(false)]
public abstract class XPObject :
XPCustomObject
<NonPersistent>
<MemberDesignTimeVisibility(False)>
Public MustInherit Class XPObject
Inherits XPCustomObject
Persistent objects are the objects that can be saved to and restored from a data store. Persistent objects represent the records in a table and encapsulate all the required relationships. The field values are represented as properties. Therefore a data table is merely represented by a collection of persistent objects. With eXpress Persistent Objects you will never have to deal with table mapping - all you need to do is to define persistent object classes, and XPO will automatically generate a database for them.
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, Optimistic Concurrency.
The following code demonstrates how to declare a persistent object.
using 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 : XPObject {
// XPObject has a built-in Integer key and you can't add a custom key
public MyClass(Session session) : base(session) { }
string fMyProperty;
public string MyProperty {
get { return fMyProperty; }
set { SetPropertyValue(nameof(fMyProperty), ref fMyProperty, value); }
}
}
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 XPObject
' XPObject has a built-in Integer key and you can't add a custom key
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
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
Object PersistentBase XPBaseObject XPCustomObject XPObject
See Also