views:

178

answers:

1

I have a WCF service that is performing some updates across a couple of databases and Active Directory. Since Active Directory is not able to support transactions, I want to implement then in a "DirectoryRepository" class that will perform a compensating action when a rollback occurs.

my code is using TransactionScope...

using(var scope = new TransactionScope())
{
       AssetRepository.Add(asset);

       DeploymentRepository.Add(deployment);

       DirectoryRepository.Add(directoryEntry);

       scope.Complete();
}

How can my DirectoryRepository be aware of any current transactions and get notified when to rollback?

+1  A: 

I think perhaps you want this

http://msdn.microsoft.com/en-us/library/ms229975.aspx

which shows how to author a resource manager that can enlist in a transaction and get notifications of e.g. rollbacks and such. (But I have not done this in a long time, I forget.)

Brian