How to "unwind" one or more InsertOnSubmit() calls
Posted: Tue 29 Aug 2017 16:29
Before stating my question: I´ll be using only one DataContext througout the entire application.
My question is as follow:
Suppose I called InsertOnSubmit() repeatedly for one or more entities, but before SubmitChanges() call, some external event (user changed her mind, some new data arrived) all the inserts must be discarded. And not to be included in some other SubmitChanges() from another part of the app.
Of course, if I were using one DataContext for this transaction only, it´s not a problem; simply Dispose it.
But because all editions must be done on instances read by the same DataContext (*), it seems to me more convenient to create the context at the app startup and use it for everything.
(*) I tried to Attach() a disconnected instance before call SubmitChanges(), but received an exception.
Any help will be appreciated.
My question is as follow:
Suppose I called InsertOnSubmit() repeatedly for one or more entities, but before SubmitChanges() call, some external event (user changed her mind, some new data arrived) all the inserts must be discarded. And not to be included in some other SubmitChanges() from another part of the app.
Of course, if I were using one DataContext for this transaction only, it´s not a problem; simply Dispose it.
But because all editions must be done on instances read by the same DataContext (*), it seems to me more convenient to create the context at the app startup and use it for everything.
(*) I tried to Attach() a disconnected instance before call SubmitChanges(), but received an exception.
Any help will be appreciated.