-
Notifications
You must be signed in to change notification settings - Fork 806
Entity Framework TableNameAttribute [Mapping]
Victor Tomaili edited this page May 3, 2021
·
1 revision
(from the official guide)
[namespace: Serenity.Data.Mapping] - [assembly: Serenity.Data]
By default, a row class is considered to match a table in database with the same name, but Row suffix removed.
If table name in database is different from row class name, use this attribute:
[TableName("TheCustomers")]
public class CustomerRow : Row
{
public string StreetAddress
{
get { return Fields.StreetAddress[this]; }
set { Fields.StreetAddress[this] = value; }
}
}
SELECT
T0.StreetAddress AS [StreetAddress]
FROM TheCustomers T0
You may also use brackets or quotes:
[TableName("[My Customers]")]
public class CustomerRow : Row
{
public string StreetAddress
{
get { return Fields.StreetAddress[this]; }
set { Fields.StreetAddress[this] = value; }
}
}
SELECT
T0.StreetAddress AS [StreetAddress]
FROM [My Customers] T0
Again, prefer brackets for database compability
See also: [ColumnAttribute](ColumnAttribute [Mapping])
Copyright © Serenity Platform 2017-present. All rights reserved.
Documentation | Serene Template | Live Demo | Premium Support | Issues | Discussions