Help using a TransactionScopeActivity with the AdoPersistenceService (Oracle) and an ORMapper

Oct 23, 2007 at 9:05 PM
Hello,

Great work so far with WFTools!
Is it possible to use custom activities that make use of an OR Mapper (LLBLGen Pro) inside of a TransactionScopeActivity if I'm using a provider that requires local transactions (IE Oracle - ODP.Net)? I'm pretty sure that the OR Mapper creates its own db connection for the persistence call. The OR Mapper uses the same DB that the persistence and tracking services are using.

Cheers,
Tariq
Coordinator
Oct 25, 2007 at 11:07 PM
Edited Oct 25, 2007 at 11:08 PM
Hi Tariq,

That largely depends on the OR Mapper... I've not used LLBLGen Pro before, but if you can pass it a connection to use then you may be in luck... Simplest case is to add the AdoWorkBatchService (using the most appropriate constructor for your provider) into your WorkflowRuntime and then from within your custom activity you can do something along these lines:

AdoWorkBatchService workflowBatchService = workflowRuntime.GetService<AdoWorkBatchService>();
IAdoResourceProvider resourceProvider = workflowBatchService.CreateResourceProvider(myConnectionStringSettings);
Boolean shouldCloseConnection;
DbConnection enlistedConnection;
try
{
enlistedConnection = resourceProvider.CreateEnlistedConnection(Transaction.Current, out shouldCloseConnection);
// do stuff with connection
}
finally
{
if (shouldCloseConnection && enlistedConnection != null)
enlistedConnection.Dispose();
}

The AdoWorkBatchRuntime will dish out a resource provider that will create a new transacted connection or re-use an existing one.

I've not tested this but, in theory, it should work just fine.

Give me a shout if it doesn't and I'll see if we can work something out!

Cheers,

Dean