Skip to main content
A newer version of this page is available. .

Base Persistent Classes

  • 2 minutes to read

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

When you define persistent business classes, there are several base persistent classes you can inherit from. The following table lists them.

Persistent Class Namespace Supported Concurrency Control Contains the Auto-Generated Primary Key Property Supports Deferred Deletion
XPLiteObject DevExpress.Xpo None (“Last in wins”) No No
XPBaseObject DevExpress.Xpo Optimistic No No
XPCustomObject DevExpress.Xpo Optimistic No Yes
XPObject DevExpress.Xpo Optimistic Yes. Integer type. Yes
BaseObject DevExpress.Persistent.BaseImpl Optimistic Yes. Guid type. Yes
DCBaseObject DevExpress.ExpressApp.Xpo Optimistic Yes. Guid type. Yes

When creating business classes from the XPO Business Object template, the BaseObject class is used. It is a recommended-to-use feature-rich persistent class. Most noticeably, it supports the optimistic concurrency control, also referred to as the optimistic locking mechanism described in the next section.

If you require your business class to use the integer type primary key, the recommended-to-use class is the XPObject class. This class also supports optimistic concurrency control.

If you need to use one of the listed classes which does not have the auto-generated primary key property, you need to define the primary key property in the business class declaration. The following code snippet illustrates this:

using System.ComponentModel;
//...
[DefaultClassOptions]
public class MyClass : XPLiteObject {
   public MyClass(Session session) : base(session) { }
   [Key(AutoGenerate = true), Browsable(false)]
   public int Oid { get; set; }
   public string MyProperty {
      get { return GetPropertyValue<string>("MyProperty"); }
      set { SetPropertyValue<string>("MyProperty", 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