Executing command inside business rules commits transaction

Ok I deleted my previous post as I narrowed this down a bit.
Bit of a weird scenario but bear with me.

Basically, I have a table with some business rules, which are implemented via a class derived from TDABusinessProcessorRules.

In this class, I’m overriding BeforeProcessChange to perform some validation. Crucially, part of this involves executing a command.

This is done by creating a TDALocalCommand object and calling the Execute method. This TDALocalCommand object has its ServiceInstance set to Sender.Service, i.e. the Service property of the Sender parameter which is the TDABusinessProcessor object. Basically creating a new TDALocalCommand object but within the context of the existing service instance.

This actually works fine but, for some reason I can’t fathom, the Execute method is committing the currently running transaction.

What’s going on here? I want the command to execute within the context of the currently running transaction (it’s only reading data, not actually modifying anything).

Is there something I’m not doing or another way of achieving this?

Tried eliminating the TDALocalCommand object and calling ExecuteCommandEx directly on the service instance but the result is the same.

Looking through the code, it seems that TDataAbstractService.InternalExecuteCommandEx is always calling DoCommitTransaction at the end (unless it rolls back of course).

My question thus becomes a general one - is there any way of executing a command on a service instance without committing any currently running transaction?


you can use DataService.OnUpdateDataCommitTransaction for overriding default behavior.

Ok thanks I’ll have a look when I get a chance :slight_smile:

1 Like