Name
This attribute sets the DbParameter.Name property value via a class property.
Attribute
Example usage:
public class Person
{
public int Id { get; set; }
[Name("ColumnName")]
public string Name { get; set; }
}
This behaves identically to the Map attribute and the Table attribute from System.ComponentModel.DataAnnotations.Schema.
Fluent Mapping
To configure via FluentMapper:
FluentMapper
.Entity<Person>()
.PropertyValueAttributes(e => e.Name, new NameAttribute("ColumnName"));
The value from the database table or view takes precedence if present.
Retrieval
Retrieve the attribute via PropertyValueAttributeCache:
var attribute = PropertyValueAttributeCache
.Get<Person>(e => e.Name)?
.FirstOrDefault(e => e.GetType() == typeof(NameAttribute));
Or via PropertyValueAttributeMapper:
var attribute = PropertyValueAttributeMapper
.Get<Person>(e => e.Name)?
.FirstOrDefault(e => e.GetType() == typeof(NameAttribute));
We strongly recommend using PropertyValueAttributeCache for maximum performance.