I want to use versioning [version] on my entities then using TXDataClient display a list in a grid. I'd like to not have to close and re-open my TAureliusDataset eveytime I post to get the latest version from the server. Is there a safe way to do this? I suspect you are going to say no but I thought I would ask anyway. I would like to do something like this
procedure TdlgPicklists.adsPicklistsAfterPost( DataSet: TDataSet );
var
old, new: TPickList;
begin
old := adsPicklists.Current< TPickList >;
new := Context.ClientApi.Get< TPickList, TGuid >( old.Id );
var
idx := picklists.IndexOf( old );
picklists[ idx ] := new;
adsPicklists.Refresh;
end;
procedure TdlgPicklists.adsPicklistsBeforeOpen( DataSet: TDataSet );
begin
FreeAndNil( picklists );
picklists := Context.ClientApi.List< TPickList >;
TAureliusDataset( DataSet ).SetSourceList( picklists );
end;
Actually you have the RefreshRecord which updates the internal dataset buffer with the updated properties of the underlying object. You cannot change the reference to the internal object as you are doing, but you could copy the properties between objects, either manually or using RTTI, for example:
procedure TdlgPicklists.adsPicklistsAfterPost( DataSet: TDataSet );
var
old, new: TPickList;
begin
old := adsPicklists.Current< TPickList >;
new := Context.ClientApi.Get< TPickList, TGuid >( old.Id );
CopyObjectPropertiesFromNewToOld(new, old);
adsPicklists.RefreshRecord;
end;