Apply changes using TFDJSONDeltasApplyUpdates

726 views Asked by At

I have this code from a tutorial from Embarcadero to pass dataset as JSON:

procedure TServerMethods1.ApplyChangesDepartmentEmployees( const ADeltaList: TFDJSONDeltas); 
var LApply: TFDJSONDeltasApplyUpdates; 
begin 

TFDJSONDeltasApplyUpdates.Create(ADeltaList); 
LApply.ApplyUpdates('Departement', FDQueryDepartment.Command); 

if LApply.Errors.Count = 0 then 
  LApply.ApplyUpdates('Emplyees', FDQueryDepartmentEmployees.Command); 

if LApply.Errors.Count > 0 then 
  Exception.Create(LApply.Errors.Strings.Text); 
end;

But I have some questions about the code:

What is TFDJSONDeltas ? and what Deltas mean ?

Why I have to create TFDJSONDeltasApplyUpdates ?

What ApplyUpdates do and what is its syntax ?

This all I got from documentation: http://docwiki.embarcadero.com/Libraries/XE8/en/Data.FireDACJSONReflect.TFDJSONDeltasApplyUpdates

1

There are 1 answers

0
Code Name Jack On BEST ANSWER

Very old question but thought of answering.

JSON Delta is a differential JSON which can be patched to an existing JSON string.

It is helpful for mobile applications where Data connection may not be consistent. 

ApplyUpdates applies a DataTable in SQL using the JSONDelta.

Syntax

LApply.ApplyUpdates('table_name', 'query.Command');