About

SubSonic is a .net open source project developed by Rob Conery and a core team of developers including Eric Kemp, Scott Watermasysk, Jon Galloway, Phil Haack, and Gavin Joyce. The current stable release is version 2.0.3. Nightly builds are available in our SVN respository.

Tags

Changing Connections On The Fly

To Change the Active Connection String (Not Necessarily with a Transaction)

 

using (SharedDbConnectionScope scope = new SharedDbConnectionScope("new connectionstring ")) { //do stuff using new connection string} // returns to default provider connection string

To Perform a Transaction With a Shared Connection

 

using (SharedDbConnectionScope sharedConnectionScope = new SharedDbConnectionScope()) using (TransactionScope ts = new TransactionScope()) { Product p = new Product(1); p.Title = "new title"; Product p2 = new Product(2); p.Title = "another new title"; // ... p.Save(); p2.Save(); ts.Close(); }
Subscribe