[英]Do I need disconnected entities?
I have a WPF application and am using entity framework. 我有一个WPF应用程序,并且正在使用实体框架。 I was reading the tutorial
我在看教程
and the author was talking about disconnected entities, which is the first time I have heard of them. 作者谈论的是断开连接的实体,这是我第一次听说它们。 I am a little confused as to when disconnected entities are actually needed, as I have been using EF just fine to do CRUD operations on my business objects.
对于实际何时需要断开连接的实体,我有些困惑,因为我一直在使用EF对我的业务对象执行CRUD操作。 If I am using the same context when I am doing CRUD operations on a business object, why do I need to ever manually track the entity state changes?
如果在对业务对象执行CRUD操作时使用的是同一上下文,为什么我需要手动跟踪实体状态更改? Thanks for any help.
谢谢你的帮助。
If you are always keeping around the originating context instance, then you probably do not need to worry about disconnected entities. 如果您始终围绕原始上下文实例,那么您可能不必担心断开连接的实体。 Disconnected entities often come up in the context of web services or web sites, where the context from which an entity was originally retrieved (and, for example, placed into a
Session
) is no longer available some time down the road when that entity has been modified and needs to be saved back to the database. 断开连接的实体通常出现在Web服务或网站的上下文中,在该上下文中,最初从中获取实体(例如,放置到
Session
)的上下文在该实体已经使用的某个时间不再可用修改并需要保存回数据库。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.