2013-03-19 53 views
0

我聽說EF4性能vise比它以前的版本更好。所以我在我的一個項目中使用了EF4。什麼是EF4中的ObjectStateManager

我需要一些關於什麼是ObjectStateManager的詳細說明,它是如何工作的。 它如何執行更新以及處理過程中在後臺發生了什麼。

回答

0

維護實體類型實例和關係實例的身份管理和對象狀態。

你可以閱讀這個鏈接誰帶來詳細講述類

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

的ObjectStateManager從ObjectContext中,並使用狀態管理的背景下,訪問對象。

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"); 
    } 
相關問題