views:

25

answers:

1

I can't seem to get an answer through google about this. If I perform updates to multiple entities at one time, attach them all to context, call Submit() and one of the updates to the entities fails, do all the changes get rolled back?

For example, in my asp.net application I have a note and a note revision table. In my asp.net application when a note is updated I want to store the new note's text in the note table, and add a new record into the note revisions table to show when this note was added and the text that was added (so users can diff to see what changed between revisions).

I want to be sure that if I update the note, but the note revision fails (or vice versa) that all changes are rolled back so data does not get out of sync. If I'm using only one datacontext for this, do I need to specifically call a transaction scope or is it not needed?

+1  A: 

Yes they do. All operations within the context of a SubmitChanges() call are committed or rolled back as a single unit of work.

If you need to make multiple SubmitChanges() calls within the context of a single transaction, use TransactionScope.

Randy Minder
Excellent thanks!
KallDrexx