Like the other DAL LOB adapters, for example, the WCF SQL Adapter, it is likely you will want to execute some operations outside of the ambient transaction. This will improve performance and allow you to access target systems that do not support distributed transactions.
To suppress the ambient transaction you will need to:
- Implement a UseAmbientTransaction binding property
- Wrap calls to target systems within a new transaction scope
bool useAmbientXact = this.Connection.ConnectionFactory.Adapter.UseAmbientTransaction;
TransactionScopeOption xactOption = (useAmbientXact ? TransactionScopeOption.Required : TransactionScopeOption.Suppress);
using (TransactionScope xactCoOrdinator = new TransactionScope(xactOption))
{
// Execute target system commands here...
}
No comments:
Post a Comment