.net - Undo changes in entity framework entities -


This may be a trivial question: because the ADONT unit framework automatically tracks changes (in generated entities) and So, how can I return the original values, changes made in unit items?

I have a form that allows the user to edit a group of "client" entities in the grid view.

Now I have two buttons "Accept" and "Back": If "Accept" is clicked, I call context.SaveChanges () and change The objects are written back to the database. If "Back" is clicked, then I want to get their original property value for all the objects. What will be the code for this?

Thanks

No reversal or change in operation in EF In each unit, objectstate enters in objectstate manager / . State entry includes the original and actual values ​​so that you can use the original values ​​to overwrite existing values, but you have to do it manually for each unit. This will not reveal changes in navigation properties / relationships.

The common way to "revert the changes" is to reconfigure the references and reload organizations. If you want to avoid reloading, then you need to clone the organizations and clone them in the new object context. Must have to modify. If the user cancels the changes, then you still have the parent bodies.

Comments