예제 #1
0
 public static void ResetModificationState(DbContext context)
 {
     foreach (var entry in context.ChangeTracker.Entries <IModificationState>())
     {
         IModificationState entity = entry.Entity;
         entity.ModificationState = ModificationState.Unchanged;
     }
 }
예제 #2
0
 /// <summary>
 /// Updates the entity state to match the modification state. This can be used to appropriately set the
 /// entity state of entire graphs in disconnected applications.
 /// </summary>
 public static void ApplyStateChanges(DbContext context)
 {
     foreach (var entry in context.ChangeTracker.Entries <IModificationState>())
     {
         IModificationState entity = entry.Entity;
         entry.State = GetEntityStateFromModificationState(entity.ModificationState);
     }
 }