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
Not sure if i get what you mean. To me T4 generation doesnt make much sense in your case but have a look at this Phil Haack approach: http://haacked.com/archive/2011/07/14/model-metadata-and-validation-localization-using-conventions.aspx
In contrast to your request he is modifying data annotations at runtime, using custom ModelMetadataProvider.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With