xpo-2058-examples-how-to-map-to-custom-tables-views-and-columns.md
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>(nameof(LastName), ref lastName, value); }
}
}
<Persistent("T_CONTACT")> _
Public Class Contact: Inherits XPObject
Private _lastName As String = ""
<Persistent("ContactLastName")> _
Public Property LastName As String
Get
Return _lastName
End Get
Set(ByVal Value As String)
SetPropertyValue(Of String)(NameOf(LastName), _lastName, Value)
End Set
End Property
End Class
See Also