Back to Devexpress

BaseObject Class

expressappframework-devexpress-dot-persistent-dot-baseimpl-ac8cae9e.md

latest4.9 KB
Original Source

BaseObject Class

Represents a base persistent class from which business classes can be inherited.

Namespace : DevExpress.Persistent.BaseImpl

Assembly : DevExpress.Persistent.BaseImpl.Xpo.v25.2.dll

NuGet Package : DevExpress.Persistent.BaseImpl.Xpo

Declaration

csharp
[NonPersistent]
public abstract class BaseObject :
    XPCustomObject
vb
<NonPersistent>
Public MustInherit Class BaseObject
    Inherits XPCustomObject

Remarks

The BaseObject class is a feature-rich persistent base class. The BaseObject class is used as the base class when declaring business classes using the XPO Business Object template. The BaseObject class’s main features are:

  • A GUID-type auto-generated BaseObject.Oid primary key property;
  • Supports optimistic concurrency control;
  • Supports deferred deletion.

The following example demonstrates how to declare a persistent class:

csharp
using DevExpress.Persistent.Base;
// ...
[DefaultClassOptions]
public class Contact : BaseObject {
    public virtual string FirstName { get; set; }
}

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.
csharp
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
// ...
[DefaultClassOptions]
public class Contact : BaseObject {
    // BaseObject contains an auto-generated Guid key, you cannot add a custom key
    public Contact(Session session) : base(session) { }
    string fFirstName;
    public string FirstName {
        get { return fFirstName; }
        set { SetPropertyValue(nameof(FirstName), ref fFirstName, value); }
    }
}

The following help topic lists base classes that you can use in XPO-based applications: Base Persistent Classes.

Business classes are inherited from a base persistent class. The Ways to Add a Business Class topic describes how to declare a business class, and the How to: Implement a Custom Base Persistent Class help topic provides details on how to implement a custom base persistent class. The Business Classes vs Database Tables topic provides a general overview of the business class concept.

Note

XAF manages persistent objects via Object Spaces. Refer to the BaseObjectSpace class description for more information about the Object Space concept.

Inheritance

Show 13 items

Object PersistentBase XPBaseObject XPCustomObject BaseObject DashboardData

MediaDataObject

ModelDifference

ModelDifferenceAspect

PermissionPolicyRoleBase

PermissionPolicyUser

ReportDataV2

PermissionPolicyRole

See Also

BaseObject Members

XPO Classes Comparison

OidInitializationMode

DevExpress.Persistent.BaseImpl Namespace