方法 :トランザクション対応クラスで AutoComplete 属性を設定する
次の例では、トランザクション対応クラスに AutoComplete 属性を配置する方法について説明します。AutoComplete 属性の詳細については、「自動トランザクションにおけるコミットおよび中止」を参照してください。
例
<Transaction(TransactionOption.Supported)> Public Class Account
Inherits ServicedComponent
<AutoComplete()> Public Sub Debit(amount As Integer)
' Do some database work. Any exception thrown here aborts the
' transaction; otherwise, transaction commits.
End Sub
End Class
[Transaction(TransactionOption.Supported)]
public class Account : ServicedComponent {
[AutoComplete]
public void Debit(int amount) {
// Do some database work. Any exception thrown here aborts the
// transaction; otherwise, transaction commits.
}
}
コードのコンパイル
この例で必要な要素は次のとおりです。
- System および System.EnterpriseServices 名前空間への参照
関連項目
概念
Copyright © 2007 by Microsoft Corporation.All rights reserved.