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
|
In one of my entity's partial class, I have overridden OnValidate method. Based on a certain criteria I am adding an Error to Errors collection. Now when I mark the entity to be removed from the UnitOfWork, and the validation fails, calling SaveChanges() still deletes the entity. Is that behavior as intended and if yes, what is suggested to validate entities which are about to be deleted? |
|
|
Is the validation failing on the entity which is being removed or another entity involved in the UnitOfWork which was affected by the removal? If its the entity being removed then that is fine, validation doesn't impact on entity removals. If you do want to check this prior you will need to manually check if the entity is valid prior to calling SaveChanges(), if you need to do this across all entities involved in the UnitOfWork the UnitOfWork object implements IEnumerable and will enumerate over all of the entities currently in scope so you can check if they are all valid.
|
|