I'm using System.ComponentModel.DataAnnotations
to provide validation for my Entity Framework 4.1 project.
For example:
public class Player
{
[Required]
[MaxLength(30)]
[Display(Name = "Player Name")]
public string PlayerName { get; set; }
[MaxLength(100)]
[Display(Name = "Player Description")]
public string PlayerDescription{ get; set; }
}
I need to retrieve the Display.Name
annotation value to show it in a message such as The chosen "Player Name" is Frank.
=================================================================================
Another example of why I could need to retrieve annotations:
var playerNameTextBox = new TextBox();
playerNameTextBox.MaxLength = GetAnnotation(myPlayer.PlayerName, MaxLength);
How can I do that?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…