OperationBehaviorAttribute::TransactionScopeRequired Property
Gets or sets a value that indicates whether the method requires a transaction scope for its execution.
Assembly: System.ServiceModel (in System.ServiceModel.dll)
Property Value
Type: System::Booleantrue if the method requires a transaction scope to execute; otherwise, false. The default is false.
Set the TransactionScopeRequired to true to require your operation to execute within a transaction scope. If a flowed transaction is available, the operation executes within that transaction. If one is not available, a new transaction is created and used for the operation execution. The binding specified in the endpoint controls whether flowed transactions are supported. Therefore, to obtain the proper behavior you must understand the interaction between whether transaction flow is permitted by the binding and the TransactionScopeRequired property. The following table shows the possible behavior.
TransactionScopeRequired | Binding permits transaction flow | Caller flows transaction | Result |
False | False | No | Method executes without a transaction. |
True | False | No | Method creates and executes within a new transaction. |
True or False | False | Yes | A SOAP fault is returned for the transaction header. |
False | True | Yes | Method executes without a transaction. |
True | True | Yes | Method executes under the flowed transaction. |
The following code example shows an operation that executes within a mandatory distributed transaction. The TransactionScopeRequired property indicates that the operation executes under a transaction scope and the TransactionAutoComplete property indicates that if no unhandled exceptions occur, the transaction scope is completed automatically. If an unhandled exception does occur, the transaction is aborted.
Available since 3.0