Calling Breeze setDetached() on an entity removed the getValidationErrors()

我们两清 提交于 2019-12-11 09:33:04

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!