locked
Dynamic Data DataAnnotations setting dynamically using t4 template RRS feed

  • Question

  • User-507312421 posted

    Hi,

    Is there any way to set dynamically the dataannotations according to some values in database?

    My requirement is like this:

    Display(Name="DispName")]

     public string DName{get;set;}

     Instead of hardcoding Name="DispName" for Display DataAnnotation, I want to fetch some value from DataBase and fit int the Name attribute. like:

     [Display(Name=SomeValueFromDB)]

    public string DName{get;set;}

    This should be done using t4 template also. Is there any way to accomplish this?

    Regards,

    Sujith

    Thursday, May 16, 2013 7:45 AM

Answers

  • User-330204900 posted

    no DataAnnotations are loaded at app startup not during runtime. This does not mean that there is not a way you can do this one way woudl be to use Resources or you could write a custom provider as I have doen here Dynamic Data – Custom Metadata Providers Matt's origional does not seem to be avaiulable any longer.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 16, 2013 8:09 AM