Sql – Linq To Sql validation

asp.net-mvclinq-to-sql

I have a class containing Linq To SQL objects that are used to populate drop downlists on a view. Using Scott Gu's Nerd Dinner I am implementing the validation framework they use, using partial classes. This works fine when working with one object for (example dinner) per view. But when I use a class that is not a Linq To Sql object, I cannot get the validation working. Any ideas?

Best Answer

The Nerd Dinner app leverages the events that are fired when Linq To SQL persists data. Specifically, the OnValidate() method.

Since you have a class that is not Linq To Sql, you can fake it by creating your own custom event handler and firing it when the data in the changes.

As an alternative, just call a method that validates a given object, calling as many validation functions as you have objects.