I’ve just noticed something odd. I’m sending a delta to the server with a single change in it which is an Update.
Now, as this table is part of a master/detail hierarchy, my update rules are set to apply Inserts & Updates separately to Deletes, as is fairly standard.
What I’m seeing is that my BeforeProcessChange method on my TDABusinessProcessorRules derived class is being called twice. Here are the relevant bits of the call stack for each call:
ContactsServer.TCompanyServerRules.BeforeProcessChange($36E67D0,ctUpdate,$37AACE8,False)
uDABusinessProcessor.TDABusinessProcessor.DoBeforeProcessChangeEvent($37AACE8,False,True)
uDABusinessProcessor.TDABusinessProcessor.ProcessDelta(TDAEFireDACConnection($43CAA04) as IDAConnection,TDADelta($377D59C) as IDADelta,[ctDelete],$5166BA0)
DataAbstractService_Impl.TDataAbstractService.BP_ProcessChanges($5166BA0,[ctDelete],False)
ContactsServer.TCompanyServerRules.BeforeProcessChange($36E67D0,ctUpdate,$37AACE8,True)
uDABusinessProcessor.TDABusinessProcessor.DoBeforeProcessChangeEvent($37AACE8,True,True)
uDABusinessProcessor.TDABusinessProcessor.ProcessDelta(TDAEFireDACConnection($43CAA04) as IDAConnection,TDADelta($377D59C) as IDADelta,[ctInsert,ctUpdate],$5166BA0)
DataAbstractService_Impl.TDataAbstractService.BP_ProcessChanges($5166BA0,[ctInsert,ctUpdate],True)
The first call is obviously for the Deletes and the second for the Inserts and Updates. What I don’t understand is why my method is being called twice. Surely, as the change in question is of type ctUpdate, it should only call the method in the second case, when processing Inserts and Updates?
In the first case, the ProcessChange parameter is set to False rather than True. I was under the impression that this (var) parameter was there for me to use to prevent the change from being applied should I so wish. Should I actually be checking the value of this parameter to see if I should be doing anything in my method? This doesn’t seem to be documented anywhere that I can see.