I managed to squeeze in enough time to implement nesting options for the DbConnectionScope class. My approach was to follow the nesting option pattern given by TransactionScope, so I added a DbConnectionScopeOptions enum with Required, RequiresNew and Suppress options. The effect of these options is entirely contained within the DbConnectionScope constructor.
Required: If Current is null, makes this instance Current. Otherwise, mark this instance as already Disposed.
RequiresNew: Same logic as original constructor — save prior value of Current to restore later and makes this instance Current.
Suppress: Saves prior value of Current to restore on Dispose and set Current to null.
I’ve also added an option to search through prior scopes for a connection. If you pass in true, the current stack of connection scopes will be searched. False means only search the current scope.
I’d like to thank Jian Zeng from the ADO.Net test team and Jim Carley from the System.Transaction team for taking the time to review the code and provide feedback prior to posting.