Handling Transactions with SubSonic 3

I was pulling data from a web service and splitting the information across multiple tables in my database, so I wanted to rollback the entire operation if one of the saves failed. SubSonic 3 can handle transactions and I did get it working as needed, but I encountered a couple of issues along the way.

  • When I attempted to save to the second table I was getting an error about a DataReader already being open. Like the guy who reported the same problem here, I was using SubSonic 3.0.03. I replaced it with version, which worked fine.
  • The example in the SubSonic documentation on transactions shows the TransactionScope code nested inside the SharedDbConnectionScope code. I found that with this setup there was no rollback on error, and the DB tables were being updated. As indicated here and here, the nesting needs to be the other way round.

About Jennifer Phillips Campbell

Software Developer and Medieval Historian
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s