So I have a ClientDataset (cdsM1) with a Nested Detail (cdsD1). I need to print it before do ApplyUpdates, so I clone them (cdsMclone and cdsDclone) and filter the master clone just to show only one master record.
After printing, I need to update the record. At first I tried something like this:
cdsMclone.Edit;
cdsMclone.FieldByName('DATEPRINTED').AsString := Now;
cdsMclone.Post;
cdsMclone.ApplyUpdates(0);
But after this, if I change anything more in the source clientdataset, cdsM1.ApplyUpdates(0)
generates a conflict (and by this I mean one that you should respond in a OnReconcileError
). But this one should not be showed to the user. Also, using this approach I am sending at least two requests to the Database.
One workaround is using CloneSource
property. Example:
cdsMclone.CloneSource.Edit;
cdsMclone.CloneSource.FieldByName('DATEWASPRINTED').AsString := Now;
cdsMclone.CloneSource.Post;
This way, I can call cdsM1.ApplyUpdates(0)
without worries. But I really don't like this. Seems the code is changing something it should not do directly. Also, how would the code looks like if in the future I need to change something in the nested detail?
There is any other way to return back changes from the cloned clientdataset to the source?