I would like to undo all the changes made to linq tables (this means - I use linq, and the data changes on the client side, the data on the server is not corrupted). How to do it?
EDIT: problem partially resolved
http://graemehill.ca/discard-changes-in-linq-to-sql-datacontext/
It works until you use a transaction. When you do and use mixed βmodeβ for recording, the problem arises:
begin trans insert a record update inserted record commit trans
When you update a record, as described above, Linq counts it as an updated record, and in case of an exception, you have two actions: the transaction is rolled back, and data from Linq are discarded. When canceling changes, Linq tries to retrieve it from the database (a reset for updating means reprogramming the data for writing), but since all changes were discarded, there are no records for updating.
Question
How to improve the DiscardChanges method in a smart general way of dealing with transactions. Or how to change the transaction workflow / drop-submissions so that they all work together?
These are not smart solutions:
- fetch all data
- recreation of the connection to the database (because it leads to (1))
source share