The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

How to: Map to Custom Tables (Views) and Columns

By default, XPO automatically designates database tables (views) and column names for objects. However, you can override the default mapping with the help of the PersistentAttribute. When applied to a class definition, the attribute's parameter specifies a table or view name. When applied to a property or field definition, the parameter specifies a column name.

In the example below, class Contact will be stored in the T_CONTACT table, and property LastName will be stored in the ContactLastName column.


[Persistent("T_CONTACT")]
public class Contact: XPObject {
    string lastName = "";
    [Persistent("ContactLastName")]
    public string LastName {
        get { return lastName; }
        set { SetPropertyValue<string>("LastName", ref lastName, value); }
    }
}
See Also