共用方式為


ChannelDispatcher.TransactionIsolationLevel 屬性

定義

取得或設定異動的預設隔離等級 (Isolation Level)。

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 狀態時才可以設定這個屬性,因為這是唯一同時處於可變動且尚未處置的狀態。

適用於