Skip to main content
.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.

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