0

Is it possible to access the value of an annotation in a model from code.

For example:

    [Table("TableA", Schema="SchemaA")]
    public class TableA
    {
        [Key]
        public decimal TABLE_ID { get; set; }
     }

Is there a way for me to get the TABLE_ID from this model by getting the "KEY" when I don't know what the actual primary key name is?

northpole
  • 10,244
  • 7
  • 35
  • 58
  • 2
    Is this any help for you? http://stackoverflow.com/questions/7047139/get-display-annotation-value-on-mvc3-server-side-code – Jason Evans Aug 13 '12 at 21:24
  • 1
    Try these http://stackoverflow.com/questions/7864662/how-i-can-find-data-annotation-attributes-and-their-parameters-using-reflection http://stackoverflow.com/questions/7027613/how-to-retrieve-data-annotations-from-code – The Internet Aug 13 '12 at 21:26
  • wow, I tried to make sure there was not a duplicate first but I guess it was. Thanks for the help, this is perfect! (I also voted to close this question) – northpole Aug 13 '12 at 21:26

0 Answers0