如何实现一个了解 TransactionScope 的类?
我有一个 WCF 服务,它正在跨几个数据库和 Active Directory 执行一些更新。由于 Active Directory 无法支持事务,因此我想在“DirectoryRepository”类中实现,该类将在发生回滚时执行补偿操作。
我的代码正在使用 TransactionScope...
using(var scope = new TransactionScope())
{
AssetRepository.Add(asset);
DeploymentRepository.Add(deployment);
DirectoryRepository.Add(directoryEntry);
scope.Complete();
}
我的 DirectoryRepository 如何了解任何当前事务并在回滚时收到通知?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想也许你想要这个
http://msdn.microsoft.com/en-us /library/ms229975.aspx
显示了如何创建一个资源管理器,该资源管理器可以加入事务并获取回滚等通知。 (不过我已经很久没这么做了,我忘记了。)
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.)