TransactionScope的选择对象不DTC [英] TransactionScope alternative without DTC

查看:286
本文介绍了TransactionScope的选择对象不DTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么替代的TransactionScope这并不需要启用DTC ??

在交易我需要两个操作:

  1. 创建一个用户(使用成员 - SQL成员资格提供)
  2. 请一个插入操作。
解决方案

的TransactionScope使用LTM - 在.net轻量级事务管理器。只有当你打开在同一事务中多个连接或数据库之间的走,要的TransactionScope促进交易的2PC型TX-经理,DTC。

有关MS SQL Server 2008和以上时,DTC将参与只有当您打开到的不同的的DB的连接。或者如果你是除非你使用的是打开的连接从多个线程在同一交易 DependentTransaction 这是你应该在全球事务中登记,如果你想要做的线程。

作为一个侧面一点:我有在 Castle.Transactions

端点#2:如果您使用的TransactionScope,一定要显式声明的IsolationLevel否则你序列化您的所有交易(IsolationLevel.Serializable)

are there any alternative to transactionScope which does not need to enable DTC??

In the transaction I need to make two operations:

  1. Create one user (using membership - sql membership provider)
  2. Do one insert operation.

解决方案

TransactionScope uses the LTM - Lightweight Transaction Manager in .Net. Only if you open more than one connection in the same transaction or go between databases, should TransactionScope promote the transaction to the 2PC-based TX-manager, DTC.

For MS SQL Server 2008 and above, the DTC will become involved only if you are opening connections to different DBs. OR if you are opening connections in the same transactions from multiple threads EXCEPT if you are using DependentTransaction which is what you should enlist in your global transaction if you want to do threading.

As a side-point: I have some support for the multi-threading story in Castle.Transactions.

Side-point #2: If you use TransactionScope, make sure to declare the IsolationLevel explicitly otherwise you're serializing all your transactions (IsolationLevel.Serializable)!

这篇关于TransactionScope的选择对象不DTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆