Is there an automatic way to generate a rollback script when inserting data with LINQ2SQL?

Posted by Jedidja on Stack Overflow See other posts from Stack Overflow or by Jedidja
Published on 2010-04-23T10:00:41Z Indexed on 2010/04/23 10:03 UTC
Read the original article Hit count: 263

Let's assume we have a bunch of LINQ2SQL InsertOnSubmit statements against a given DataContext. If the SubmitChanges call is successful, is there any way to automatically generate a list of SQL commands (or even LINQ2SQL statements) that would automatically undo everything that was submitted? It's like executing a rollback even though everything worked as expected.

Note: The destination database will either be Oracle or SQL Server, so if there is specific functionality for both databases that will achieve this, I'm happy to use that as well.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about sql-server