IValidatableObject

Jul 29, 2014 at 9:26 PM
One more question: How/where would one implement IValidatableObject, to accomplish UI validation? I would surmise that, for a Product entity, it would be by either modifying the (in this example) Product.cs to add the inherit from IValidatableObject to that class definition, or a separate file (say ProductValidation.cs) with a "partial class Product : IvalidatableObject" that has the validation code within it. Or perhaps put that separate ProductValidation.cs file in the Service project to sit alongside the Product's Entity and Interface classes? Which would you recommend?
Coordinator
Aug 1, 2014 at 6:43 PM
Put the ProductValidation.cs in the a separate file, the notion around PoCo's are they are what they are (Plain old C# Objects), and should be nothing more than that. As far as to where this class lives, is whatever you think makes the most sense (e.g. It could be placed in Northwind.Entites, Northwind.Services, or Northwind.Validations).
Marked as answer by lelong37 on 8/1/2014 at 10:43 AM
Aug 1, 2014 at 9:06 PM
Thanks Le!
Jun 12, 2015 at 1:53 PM
I am bit new to this.

You mentioned putting the validation in another file.. What I am curious about is the correct approach for validation.
For example I have a POCO called Dock that has an SiteID field referencing a SiteId in a POCO called Site.

I want to ensure when the unitOfWork.SaveChanges(); is fired it ensures that the DOCK has a valid SiteId assigned and if not kick back an error or valiation message letting the developer know that a valid SiteId is required.

Is there an article I can read over covering this topic?