Hellow,
I had implement the following service in order to save (Insert,Update,Delete) a single master entity with a ManyValuedAssociation Entity
// Server side service
function TCoreService.Saveitemdoctype(_ItemDocType:TItemdocType): String;
var id:integer;
aItemDocType:TItemDocType; //Master Entity
aItemDocTypeSeries:TItemDocTypeSeries; // Associated Entity
begin
try
for aItemDocTypeSeries in _ItemDocType.ItemDocTypeSeries do
begin
if aItemDocTypeSeries.ID=0 then
begin
// Insert here a new detail which is not having an ID, means it is a new inserted detail because of TIdGenerator.None
aItemDocTypeSeries.ID:=GetNextID('ItemDocTypeSeries');
TXDataOperationContext.Current.GetManager.Save(aItemDocTypeSeries) ;
end
else
// update my detail
TXDataOperationContext.Current.GetManager.SaveorUpdate(aItemDocTypeSeries);
// the missing part here deleted details
end;
TXDataOperationContext.Current.GetManager.SaveorUpdate(_ItemDocType);
TXDataOperationContext.Current.GetManager.Flush;
TXDataOperationContext.Current.GetManager.Connection.BeginTransaction.Commit;
result:='COMMITED';
except
TXDataOperationContext.Current.GetManager.Connection.BeginTransaction.Rollback;
result :="UNCOMMITED";
end;
end;
my questions are:
a) how do I know which detail was deleted on client since the Object passed as a parameter contains only the current assosiated objects?
b) is there any property or function to access a "delta" like in the TClientDataset where we know which record is Modified, deleted or inserted?
On the delphi client side I use to post:
procedure TForm1.MasterObjectUpdate(Dataset: TDataSet; AObject: TObject);
begin
XClient.Service<ICoreService>.Saveitemdoctype(AObject as TItemDocType);
end;