0

我听说 EF4 的性能比以前的版本更好。所以我在我的一个项目中使用了 EF4。

我需要一些关于它是什么ObjectStateManager以及它是如何工作的详细描述。它如何执行更新以及处理时在后台发生了什么。

4

2 回答 2

0

这是我不久前在搜索时遇到的一个很好的答案

http://entityframeworktutorial.net/objectstatemanager.aspx#.UUhjRRwjzQU

于 2013-03-19T13:11:23.373 回答
0

维护实体类型实例和关系实例的身份管理和对象状态。

您可以阅读此链接,该链接提供有关课程的详细信息

http://msdn.microsoft.com/fr-fr/library/system.data.objects.objectstatemanager.aspx

来自 ObjectContext 的 ObjectStateManager 并使用状态管理器访问上下文中的对象。

ObjectStateManager objectStateManager = context.ObjectStateManager;
    ObjectStateEntry stateEntry = null;

    var order = (from o in context.SalesOrderHeaders
                 where o.SalesOrderID == orderId
                 select o).First();

    // Attempts to retrieve ObjectStateEntry for the given EntityKey.
    bool isPresent = objectStateManager.TryGetObjectStateEntry(((IEntityWithKey)order).EntityKey, out stateEntry);
    if (isPresent)
    {
        Console.WriteLine("The entity was found");
    }
于 2013-03-19T13:08:15.620 回答