开发者

How does EntityState, HasChanges, HasPropertyChanges work on Partial Classes?

开发者 https://www.devze.com 2023-01-05 18:39 出处:网络
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. B

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 m开发者_开发问答ore correct way to do this?

Using: MVVM, SL4, EF, WCF RIA Services.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号