I'm not a DNN user, but whithin the context of a CLR transaction any ADO.Net operation will automatically enroll into the transaction:
using(TransactionScope scope = new TransactionScope(
TransactionScopeOption.Required))
{
UserController.CreateUser(ref UserInfo)
...
scope.Complete();
}
Unless some DNN code explicitly disables the transaction scope (by creating a new scope with the option Supress
) then the actual database work will be enrolled in the appropiate transaction (eg. any SqlClient operation will be enrolled into a SqlTransaction).
Update
Transaction scope is a context object that is associated with the current thread. Once created, .Net components that check for its existence will find it and know that they have to participate in the transaction.
File operation cannot enroll into a transaction scope because the underlying file system does not support transactions (at least not until Win7). Components like SQL Server provider, Oracle Provider, MSMQ accessor and other .Net components that support transactions will start a transaction and add it to the current scope. When the scope is 'complete', the equivalent SqlTransaction is committed. If the scope 'ends' (ie. its Dispose method is called because it reaches the end of the using
block) but does not 'complete', the SqlTransaction is rolled back.
If multiple components enroll in a single transaction scope then they will become part of a distributed transaction. This can happen with something as simple as using two separate connections while under a transaction scope. The ADO.Net will automatically enroll them in a true distributed transaction.