Skip to main content
.NET Framework 4.5.2+

PersistentAttribute Class

Indicates that a property, field or class will be stored in a persistent data store and specifies the target column or table name.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v23.1.dll

NuGet Package: DevExpress.Xpo


[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface, Inherited = true)]
public sealed class PersistentAttribute :


Generally, XPO stores only writable properties and public fields. Use the PersistentAttribute whenever you want to force persistence for non-writable or non-public fields (for instance, if you need to store a read-only property value to the database). Use the PersistentAttribute.MapTo parameter to specify the column name for the property or field to persist.

This attribute can also be applied to a class to make it persistent and to map objects of this class to a specific table/view in a data store. Only a single class can be mapped to a specific table/view. Otherwise, an SameTableNameException exception will be raised.

A persistent class, that is a descendant of another persistent class, can be mapped to the table to which its ancestor is mapped using the MapInheritanceAttribute attribute.

To map a class to a table in a specific schema, prefix the table name with the schema name. For example: “MySchema.MyTable”. Note that the specified schema name must already exist in the database. Also, some connection providers allow you to specify a common schema name for all classes in the ObjectsOwner field of the connection provider. This field is implemented by SQL Server, SQL Server CE, Oracle, PostreSQL, and DB2 connection providers.

It’s also possible to make an object persistent by implementing the IXPSimpleObject or IXPObject interface or by deriving it from the XPBaseObject class or one of its descendants.


The following example shows different functions of the PersistentAttribute. It is used for: specifying the table name to which the Person class is mapped, specifying the column name to which the FullName property and the mDefaultAddress field are mapped, and to make the private field (mDefaultAddress) persistent.

The PersistentAliasAttribute is used here to allow accessing the persistent mDefaultAddress field in criteria via the read-only DefaultAddress property’s name.

using DevExpress.Xpo;

public class Person : XPLiteObject {


    public string FullName {
        get { return GetPropertyValue<string>(nameof(FullName)); }
        set { SetPropertyValue<string>(nameof(FullName), value); }

    private string mDefaultAddress;

    public string DefaultAddress {
        get { return mDefaultAddress; }


See Also