EntityState、HasChanges、HasPropertyChanges 如何在部分类上工作?
我有一个来自 EntityFramework 的类,我在部分类中扩展了一些属性。我在界面中公开并编辑这些属性的值,一切正常。但是,我想检测 ViewModel 中属性值的变化,并且在调查集合中的 EntityState、HasChanges、HasPropertyChanges 属性时,它们都是未修改的或错误的?!即使我可以看到我的属性的值已更改...
那么,我是否必须对我的部分类执行任何特殊操作才能更新 HasChanges、HasPropertychanges 标志或 EntityState? 依赖属性是更正确的方法吗?
使用:MVVM、SL4、EF、WCF RIA 服务。
I have a class coming from EntityFramework which I have extended with a few properties in a partial class. I expose and edit the values of these properties in my interface and everything works fine. But, I want to detect the change of value in the properties in my ViewModel, and while investigating the EntityState, HasChanges, HasPropertyChanges Properties on my collection they are all unmodified or false?! Even though I can see that the value of my properties has changed...
So, do I have to do anything special on my partial class for it to update the HasChanges, HasPropertychanges flag or the EntityState?
Is dependency properties a more correct way to do this?
Using: MVVM, SL4, EF, WCF RIA Services.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,EF 不对不属于 EF 模型一部分的属性进行更改跟踪。自我跟踪实体可以改变这一点,但它们可能不应该改变。您不应尝试将 EF 的更改跟踪机制重新用于非 EF 用途。它所带来的破坏可能比它所修复的还要多。
The EF, by default, does no change tracking on properties which are not part of the EF model. Self-tracking entities can change this, but they probably should not. You should not try and re-purpose the EF's change tracking mechanism for non-EF uses. It's likely to break more than it fixes.