FireDAC ApplyUpdates without clearing the Delta

719 views Asked by At

Is it possible to call Applyupdates on a FireDAC Query on cached updates mode without clearing its Delta ?.

The reason to do so is because I have 4 FDQuerys that I want to save together or cancel together if any of them raises on error. I could use a single transaction to rollback all changes if any problem happens, but that would leave the Delta empty for every FDQuery where its ApplyUpdates were successful.

So I would like to call some kind of ApplyUpdates that doesn't clear the Delta, and only if all the FDQuerys ApplyUpdates are successful then I would Commit the Transaction and call CommitUpdates on every FDQuery to clear their Deltas. But if one of them fails the changes of every FDQuery would still remain in their Deltas, so I Rollback the transaction and the user can still fix the data and try to save them again.

Update: As @Brian has commented, setting the property UpdateOptions.AutoCommitUpdates to False does the trick and doesn't clear the Delta.

1

There are 1 answers

1
Brian On BEST ANSWER

Setting UpdateOptions.AutoCommitUpdates to false will leave the deltas alone when ApplyUpdates is called. The current help for AutoCommitUpdates is lacking however and describes the False setting incorrectly in a confusing way. It should be by more like:

AutoCommitUpdates controls the automatic committing of cached updates.

Specifies whether the automatic committing of updates is enabled or disabled.

  • If AutoCommitUpdates is True, then all the successfully updated records applied by the call to ApplyUpdates are automatically marked as unchanged. You do not need to explicitly call CommitUpdates.
  • If AutoCommitUpdates is False, then your application must explicitly call CommitUpdates to mark all changed records as unchanged.

I put in a ticket to fix the help: RSP-31141