简体   繁体   English

我是否需要断开连接的实体?

[英]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.

相关问题 我需要定义这两个实体之间的任何关系吗? - Do I need to define any relationship between these two entities? EF Core 中断开连接的实体 - Disconnected Entities in EF Core 在使用EF Fluent API映射我的实体关系时,我是否需要同时映射涉及的两个实体? - When using EF Fluent API to map my entities relationships, do I need to map on both entities involved? 以断开连接模式删除多个实体 - delete multiple entities in disconnected mode 需要包括()相关实体,但没有其他选择 - Need to Include() related entities but no option to do so 我是否需要使用EntityFramework更新一对多关系中的两个实体? - Do I need to update both Entities in a one-to-many relationship using EntityFramework? 仅在插入数据库时​​是否必须使用断开连接的方法? - Do I have to use a disconnected approach when only inserting in a database? 如何识别当前断开连接的配对的蓝牙设备? - How do I identify a paired Bluetooth device that's currently disconnected? 使用实体框架6插入断开连接的相关实体 - Inserting Disconnected Related Entities with Entity Framework 6 如何通过Web API跟踪断开连接的实体 - How to track disconnected entities over Web API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM