Call AcceptAllChanges() to accepts the changes on all associated entries in
the ObjectStateManager
so their resultant state is either unchanged or detached.
This method
iterates all the ObjectStateEntry
objects within the ObjectStateManager
that are Added or Modified, and then sets the state of the entry to Unchanged.
The Deleted items become detached.
SaveChanges()
persists all updates to the data source and resets change tracking in the object
context. It operates within a transaction. SaveChanges
will roll back that transaction and throw an exception if any of the dirty
ObjectStateEntry
objects cannot be persisted.
If the SaveChanges
method was called and the AcceptAllChangesAfterSave
was not specified, the user must call the AcceptAllChanges method. The
AcceptAllChanges method is useful in the scenario where a transaction has
failed and a user wants to retry.
Reference:
http://msdn.microsoft.com
Entity Framework: SaveChanges()和AcceptAllChanges()方法,布布扣,bubuko.com
Entity Framework: SaveChanges()和AcceptAllChanges()方法
原文:http://www.cnblogs.com/sungang3225/p/3644402.html