Is there any way to validate using DataAnnotations in WPF & Entity Framework?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the DataAnnotations.Validator class, as described here:
http://johan.driessen.se/archive/2009/11/18/testing-dataannotation-based-validation-in-asp.net-mvc.aspx
But if you’re using a “buddy” class for the metadata, you need to register that fact before you validate, as described here:
http://forums.silverlight.net/forums/p/149264/377212.aspx
[Added the following to respond to Shimmy’s comment]
I wrote a generic method to implement the logic above, so that any object can call it:
In each object that needs to be validated, I add a call to this method: