TransactionAttribute Class
.NET Framework 3.0
Specifies the type of transaction that is available to the attributed object. Permissible values are members of the TransactionOption enumeration.
Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
[ComVisibleAttribute(false)] [AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] public sealed class TransactionAttribute : Attribute
/** @attribute ComVisibleAttribute(false) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ public final class TransactionAttribute extends Attribute
ComVisibleAttribute(false) AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) public final class TransactionAttribute extends Attribute
Not applicable.
If a transaction type is specified with this attribute, it must not be changed in the COM+ catalog. If the transaction type is changed in the COM+ catalog, the same transaction type must be specified on the component with this attribute.
For more information about using attributes, see Extending Metadata Using Attributes.
The following code example demonstrates the use of the TransactionAttribute to mark a ServicedComponent as transactional.
[Transaction] public class TransactionalComponent : ServicedComponent { public void TransactionalMethod (string data) { ContextUtil.DeactivateOnReturn = true; ContextUtil.MyTransactionVote = TransactionVote.Abort; // Do work with data. Return if any errors occur. // Vote to commit. If any errors occur, this code will not execute. ContextUtil.MyTransactionVote = TransactionVote.Commit; } }
/** @attribute Transaction()
*/
public class TransactionalComponent extends ServicedComponent
{
public void TransactionalMethod(String data)
{
ContextUtil.set_DeactivateOnReturn(true);
ContextUtil.set_MyTransactionVote(TransactionVote.Abort);
// Do work with data. Return if any errors occur.
// Vote to commit. If any errors occur, this code will not execute.
ContextUtil.set_MyTransactionVote(TransactionVote.Commit);
} //TransactionalMethod
} //TransactionalComponent
Community Additions
ADD
Show: