ChannelDispatcher.TransactionIsolationLevel 属性

定义

获取或设置事务的默认隔离级别。

public:
 property System::Transactions::IsolationLevel TransactionIsolationLevel { System::Transactions::IsolationLevel get(); void set(System::Transactions::IsolationLevel value); };
public System.Transactions.IsolationLevel TransactionIsolationLevel { get; set; }
member this.TransactionIsolationLevel : System.Transactions.IsolationLevel with get, set
Public Property TransactionIsolationLevel As IsolationLevel

属性值

IsolationLevel

IsolationLevel 值之一。 默认值为 Unspecified

例外

隔离级别设置未定义。

通信对象处于 OpeningOpened 状态。

通信对象处于 ClosingClosed 状态。

通信对象处于 Faulted 状态。

示例

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

serviceHost.Open();

IChannelListener icl = serviceHost.ChannelDispatchers[0].Listener;
ChannelDispatcher dispatcher = new ChannelDispatcher(icl);
dispatcher.TransactionIsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
Dim baseAddress As New Uri("http://localhost:8001/Simple")
Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

serviceHost.Open()

Dim icl As IChannelListener = serviceHost.ChannelDispatchers(0).Listener
Dim dispatcher As New ChannelDispatcher(icl)
dispatcher.TransactionIsolationLevel = System.Transactions.IsolationLevel.ReadCommitted

注解

使用 TransactionIsolationLevel 属性来获取或设置由服务的调度程序创建的新事务的默认隔离级别。

只有当 ChannelDispatcher 的实例处于 Created 状态时才可以设置此属性,因为该状态是唯一一个可变且不被释放的状态。

适用于