Back to Devexpress

Base Persistent Classes

expressappframework-113146-business-model-design-orm-business-model-design-with-xpo-base-persistent-classes.md

latest3.6 KB
Original Source

Base Persistent Classes

  • Feb 20, 2026
  • 2 minutes to read

This topic describes the base persistent classes that can be used in XAF applications when creating a data model with XPO.

The following table lists the base persistent classes you can inherit from when you define persistent business classes:

Persistent ClassNamespaceSupported Concurrency ControlContains the Auto-Generated Primary Key PropertySupports Deferred Deletion
XPLiteObjectDevExpress.XpoNone (“Last in wins”)NoNo
XPBaseObjectDevExpress.XpoOptimisticNoNo
XPCustomObjectDevExpress.XpoOptimisticNoYes
XPObjectDevExpress.XpoOptimisticYes. Integer type.Yes
BaseObjectDevExpress.Persistent.BaseImplOptimisticYes. Guid type.Yes

The BaseObject class is used when creating business classes from the XPO Business Object template. It is a feature-rich persistent class that supports the optimistic concurrency control (optimistic locking mechanism).

We recommend using the XPObject class if your business class should use the integer type primary key. This class also supports optimistic concurrency control.

You need to define the primary key property in the business class declaration if you are using classes which do not have the auto-generated primary key property. The following code snippet illustrates this:

csharp
using System.ComponentModel;
using DevExpress.Persistent.Base;
using DevExpress.Xpo;
//...
[DefaultClassOptions]
public class MyClass : XPLiteObject {
    public MyClass(Session session) : base(session) { }
    [Key(AutoGenerate = true), Browsable(false)]
    public int Oid { get; set; }
    string fMyProperty;
    public string MyProperty {
        get { return fMyProperty; }
        set { SetPropertyValue(nameof(MyProperty), ref fMyProperty, value); }
    }
}

If you need to consider whether to use a base class that supports the deferred deletion feature, refer to the XPO documentation: Deleting Persistent Objects.

You can implement a custom base persistent class. To learn more, refer to the How to: Implement a Custom Base Persistent Class help topic.

See Also

Optimistic Concurrency Control

Built-in Controllers and Actions in the System Module

XPO Classes Comparison

Delete Persistent Objects

Optimistic Concurrency

Web - How to avoid issues with data-bound controls due to missing or non-unique key values