Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add data annotations programmatically

I am working on an asp mvc3 app that is using .NET 4.

However the model I want to use is in a class library that is using .NET 3.5 and cannot change.

Can I add the .NET 4 data annotations to some properties in my model in the controller programatically to get some easy validation?

like image 644
aaron Avatar asked Dec 06 '11 02:12

aaron


1 Answers

Create your own ModelMetadataProvider and this should do want you want

http://www.dotnetcurry.com/ShowArticle.aspx?ID=715

like image 61
Adam Tuliper Avatar answered Sep 21 '22 18:09

Adam Tuliper