-
Notifications
You must be signed in to change notification settings - Fork 0
Mapping Attributes
When using the Property Name method for initializing a repository, attributes can be used on the class and properties to configure the database mapping.
The TableNameAttribute can be used to manually set the name of the database table if the name doesn't match the class name
Placement: Class
Example:
[TableName("databaseTableName")]
public class Person {The AutonumberAttribute is used to map a property as a primary key with autonumber/autoincrement
Placement: Property
Example:
[Autonumber]
public int ID { get; set; }The KeyMapAttribute is use to map a property as a primary key. Similar to [Key] in EntityFramework.
Placement: Property
Example:
[KeyMap]
public int ID { get; set; }The ColumnMapAttribute is use to set a column name that is different from the property name. Similar to [Column] in EntityFramework.
Placement: Property
Example:
[ColumnMap("Active")]
public bool IsActive { get; set; }The SkipMappingAttribute is used to prevent mapping a property to a database column. Use this if you have an extra property that doesn't match any database column. Similar to [NotMapped] in EntityFramework.
Placement: Property
Example:
[SkipMapping]
public string PropertyWithoutDatabaseColumn { get; set; }