This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I was thinking that when calling Validate() on an entity I would get a list of all validation errors, including those associated with the ValidateUnique Attribute. But apparently uniqueness of a property only applies when one tries to commit the entity to the database. Is it reasonable to assume that a call to Validate() will check the uniqueness of a property with values in the database at that time to avoid a ValidationException when trying to commit the entity? It doesn't feel like an exceptional situation so now I am forced to create a method on my repository to do the same thing that ValidateUnique does. Regards, Dave |
|
|
ValidateUnique does get run as part of validation, but it only works if the entity is associated with a unit of work. (If it's not associated with a unit of work, we don't know which database to check against.) Have you added the entity to the UOW at the time you call Validate? |
|
|
Good point. I didn't add it to the Unit Of Work. If I do add it to the uow then it does show the error when calling Validate(). I will have to re-think when I want to perform validation. Thanks, Dave |
|