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 have an Entity with a field (Code) that has ValidateUnique. We are allowing the user to create multiple Entities without saving each individually. When I create a new Entity and give it a code that clashes with another new Entity it does not show as invalid (even if I call Validate). The Entities are attached to a UnitOfWork. How do I get one or both of the duplicate Codes to show as invalid?
|
|
|
The built-in uniqueness validation works through a database query, so it will only test against entities that are in the database. You can override OnValidate to also check against entities in the unit of work by examining this.UnitOfWork.OfType<Widget>().Any(w => w.EntityState == EntityState.New && w != this && w.Code == this.Code). |
|