How do I manually do the work of the DataAnnotationsModelValidatorProvider after disabling automatic validation application wide (a la https://stackoverflow.com/a/6111442/236255). I ask because
- I like how it works and want to leverage its functionality, but
- I typically need to do business validation that needs to talk to the database in addition to the usual DataAnnotations-based validation. I could create and dispose of my L2S
DataContextwithin theIValidatableObject.Validatemethod, but that seems to go against the DI pattern of injecting services and data contexts into my controllers (fighting my functional programmer temptation to write my services as static methods that create and dispose of data contexts themselves!).
Note that I don’t use any of the MVC client validation features (I do all POSTs as ajax, so I have never seen any real benefit to client side validation).
First, Validate:
Then, copy the results to ModelState: