如何:对事务识别类设置 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 命名空间。

请参见

概念

自动事务中的投票

Footer image

版权所有 (C) 2007 Microsoft Corporation。保留所有权利。