c# - Entity Framework: SaveOptions.AcceptAllChangesAfterSave vs SaveOptions.DetectChangesBeforeSave -


what difference between saveoptions.acceptallchangesaftersave , saveoptions.detectchangesbeforesave in entity framework? when use saveoptions.none?

these options provided in objectcontext.savechanges(saveoptions options).

can of these option, in way, used reverse changes made objectcontext.savechanges()?

they're 2 entirely different things. note how saveoptions has flags attribute: indicates can combine multiple flags, in case make saveoptions.acceptallchangesaftersave | saveoptions.detectchangesbeforesave.

and if you're wondering saveoptions.none | saveoptions.acceptallchangesaftersave, keep in mind saveoptions.none 0 value, long-winded way of writing saveoptions.acceptallchangesaftersave.

so use saveoptions.none when want neither saveoptions.acceptallchangesaftersave nor saveoptions.detectchangesbeforesave.

can of these option, in way, used reverse changes made objectcontext.savechanges()?

in context? if don't include saveoptions.acceptallchangesaftersave, changes preserved locally unsaved. added entities remain in "added" state, modified entities remain in "modified" state, deleted entities still available explicitly requesting context's deleted entities. attempting save again fail, database has been updated. can use regular methods reverting unsaved changes, requires lot of manual work on part, requires manually looking original values of properties , restoring value. detailed example of how is, think, beyond scope of question, see undo changes in entity framework entities.

in database? requires more work on part, , may not possible @ all: once entity server-generated column (e.g. auto-increment key, or row version field), impossible restore exact same values had.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -