EF 4.1 DBContext AutoDetectChangesEnabled [英] EF 4.1 DBContext AutoDetectChangesEnabled

查看:191
本文介绍了EF 4.1 DBContext AutoDetectChangesEnabled的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

行。我已经关闭AutoDetectChangesEnabled,当我查询上下文时,修改一个实体并尝试保存更改,没有任何更新。我会期待的。



但是,当我将实体标记为修改时,我希望它会更改。



任何想法?



我正在使用UnitOfWork,Repository,服务模式。



如果我启用AutoDetectChangesEnabled,一切都很好。



持续更改附加对象的标准方法是什么?



分离对象感谢提前,
Sam

解决方案

  ObjectContext.ObjectStateManager 
.ChangeRelationshipState(分辨率,分辨率.Message,r => r.Message,EntityState.Added);


OK. I have turned off AutoDetectChangesEnabled, and when I query the context, modify an entity and attempt to save changes, nothing gets updated. I would expect that.

But when I mark the entity as modified, I would expect it to change.

Any ideas?

I am using the UnitOfWork, Repository, Service pattern.

If I enable AutoDetectChangesEnabled then all is fine.

What is the standard way to persist changes to attached objects?

What about detached objects?

Thanks in advance, Sam

解决方案

It's not just entities what is tracked, but relations as well.

ObjectContext.ObjectStateManager
      .ChangeRelationshipState(resolution, resolution.Message, r => r.Message, EntityState.Added);

这篇关于EF 4.1 DBContext AutoDetectChangesEnabled的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆