I'm writing an application using LinqToSQL. Basically the application
works as follows:
- Read a file
- Add rows to the database (the rows belong to more than one table).
- Call DataContext.SubmitChanges() to presis those rows into the
database.
It might be possible that there are problems in the datal. In this
case, the rows donīt need to be inserted into the database. So I donīt
call SubmitChanges. However, this scenario causes serious issues.
Since there is no CancelUpdate, LINQ to SQL will attempt to add the
data from the earlier attempt, which probably is corrupt. The only way
to recover is to restart the application!
I really like the transaction idea of Linq: make a lot of changes and
Linq applies them in batch. However, as far as I know there is no way
to cancel these changes, which is a huge drawback. Am I overlooking
something? Is there some way to cancel the pending changes? Or do I
need to keep track of each and every object I either modify or insert
and revert the changes myself?
Any pointers would be greatly appreciated!
Kind regards,
Bram Fokke