【发布时间】:2012-11-27 09:51:35
【问题描述】:
我需要从我的数据库上下文中返回一个新添加对象的列表。
我已经读到我必须为此目的使用ObjectStateManager。问题是,我的数据库上下文没有 ObjectStateManager 属性。
尽管上下文可以很好地检索、添加和更新对象。
我正在使用 EF 5.0
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
我能做什么?
【问题讨论】:
-
“我必须为此使用 ObjectStateManager。” -- 如您所见,
ObjectStateManager仍然有效,但您不需要它。DbContext派生类可以使用ChangeTracker属性来获取该信息。
标签: c# entity-framework