MVC mapping to specific column?
I have the following class below.
[Bind()]
[Table("Actives", Schema = "Actives")]
public class Active
{
[Key()]
public int ID { get; set; }
[Required(ErrorMessage="Du skal angive et nummer for denne aktiv.")]
[DisplayName("Nummer")]
public int Number { get; set; }
[Required(ErrorMessage = "Du skal angive hvilken type aktiven er.")]
[DisplayName("Aktiv-type")]
[Column(TypeName = "int")]
public ActiveType ActiveType
{
get;
set;
}
开发者_StackOverflow社区 [Column(TypeName = "int")]
[DisplayName("Sted")]
public Place Place
{
get;
set;
}
}
How can I specify that my "Place" and "ActiveType" properties should match to the "Place_ID" and "ActiveType_ID" columns?
I'm not sure I'm understanding your question correctly, but can't you use the Name
property for the Column
attribute?
[Required(ErrorMessage = "Du skal angive hvilken type aktiven er.")]
[DisplayName("Aktiv-type")]
[Column(TypeName = "int", Name="ActiveType_ID")]
public ActiveType ActiveType
{
get;
set;
}
[Column(TypeName = "int", Name="Place_ID")]
[DisplayName("Sted")]
public Place Place
{
get;
set;
}
Link to MSDN docs on ColumnAttribute.
精彩评论