TypeMap
This attribute maps a property to a specific database type via System.Data.DbType.
This attribute takes precedence over the type-level mapping defined in TypeMapper.
The following example maps a System.DateTime property to DbType.DateTime2:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
[TypeMap(DbType.DateTime2)] // Mapping this to 'DateTime2'
public DateTime DateOfBirth { get; set; }
}
The following example maps a byte[] property to DbType.Binary:
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
[TypeMap(DbType.Binary)] // Mapping this to 'Binary'
public byte[] Image { get; set; }
}