问题
Is it an expected behaviour that the array of validations on the entity is destroy when the entity is detached or if you create an entity and you don't add it to the manager (so it's in a 'detached' state), it doesn't have the validation set on your model ? This is problematic as I am creating a form dynamically with angular and breeze based on the entity selected or created and I need those validations
回答1:
Yes, that is correct. A detached entity does not validate property changes because it is not aware of those changes. The EntityManager is responsible for watching property changes and a detached entity (by definition) does not have an EntityManager.
It is also a fact that detaching an entity clears any validation errors it happens to have. I don't know why we chose that behavior (I'm sure there is a good reason). I can only report that it is so.
You can force validation of a detached entity by calling detachedEntity.entityAspect.validateEntity();
These behaviors are on display in the DocCode sample's validationTests.js - "Detaching entity clears validation errors".
And now a question for you: why are you creating and binding to a detached entity?
来源:https://stackoverflow.com/questions/19530072/calling-breeze-setdetached-on-an-entity-removed-the-getvalidationerrors