There is a functionality to cancel and rever to original values?
This can be usefull whan I start a transaction ad it's fail...
You can use Refresh method to revert objects to their state in database.
var
LAddress: TCustomAddress;
LCustomer: TCustomer;
begin
LCustomer := DBMgr.Find<TCustomer>(CustomerID);
DBConn.StartTransaction;
try
for LAddress in LCustomer.AddressList do
begin
LAddress.Street := 'NewValue';
end;
raise Exception.Create('This is an exception');
except
DBConn.Rollback;
raise;
end;
end;
If a manual SavePoint/RestorePoint is an option, then that's an interesting suggestion, indeed.
Oh yes if you can implement this...for me is very very good.
To bypass this problem I've created a simple TJSONValue field into store a serialized object and I want to restore this JSON when the user click cancel, but when I deserialize the TCustomer the address list is not restored.
Unloaded proxies are serialized with proxy info. It's described here:
Oh yes I see it again. But it's very complex to do a simple operation :(
you can implement any code you want to retrieve the proxy value. The example shows a request to DataSnap to retrieve the value, but you can just performa a Find operation in a TObjectManager to retrieve the object.
Actually TObjectManager has a ProxyLoad method that receives a IProxyInfo directly and gives you the correct object.
Yes but I don't want to retrieve it with a Find I need this child to be restored from JSON and not reloaded from ObjectManager or database.
Haven't you just said you don't use DataSnap and want to retrieve it locally? Convert the JSON to IProxyInfo as showed in the example then call ProxyLoad instead of RemoteProxyLoad.