EntityState、HasChanges、HasPropertyChanges 如何在部分类上工作?

发布于 2024-09-07 15:05:25 字数 315 浏览 4 评论 0原文

我有一个来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鼻尖触碰 2024-09-14 15:05:25

默认情况下,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文