ApplyChanges
服务端
procedure TServerMethods1.ApplyChanges( const ADeltaList: TFDJSONDeltas);
var
LApply: IFDJSONDeltasApplyUpdates;
begin
// Create the apply object
LApply := TFDJSONDeltasApplyUpdates.Create(ADeltaList);
// Apply the department delta
LApply.ApplyUpdates('人员', FDQuery1.Command);//人员是tablename
if LApply.Errors.Count > 0 then
// Raise an exception if any errors.
raise Exception.Create(LApply.Errors.Strings.Text);
end;
var
LApply: IFDJSONDeltasApplyUpdates;
begin
// Create the apply object
LApply := TFDJSONDeltasApplyUpdates.Create(ADeltaList);
// Apply the department delta
LApply.ApplyUpdates('人员', FDQuery1.Command);//人员是tablename
if LApply.Errors.Count > 0 then
// Raise an exception if any errors.
raise Exception.Create(LApply.Errors.Strings.Text);
end;
客户端
function TForm1.GetDeltas: TFDJSONDeltas;
begin
fdmemtable1.CachedUpdates:=true;
begin
fdmemtable1.CachedUpdates:=true;
// fdmemtable1属性 CachedUpdates 注意CachedUpdate要设置为True。否则即使Post,Delta也是空的
if FDMemTable1.State in dsEditModes then
begin
FDMemTable1.Post;
end;
// Create a delta list
Result := TFDJSONDeltas.Create;
// Add deltas
TFDJSONDeltasWriter.ListAdd(Result,'人员' ,FDMemTable1););//人员是tablename
end;
if FDMemTable1.State in dsEditModes then
begin
FDMemTable1.Post;
end;
// Create a delta list
Result := TFDJSONDeltas.Create;
// Add deltas
TFDJSONDeltasWriter.ListAdd(Result,'人员' ,FDMemTable1););//人员是tablename
end;
procedure TForm1.Button2Click(Sender: TObject);
var
LDeltaList: TFDJSONDeltas;
begin
LDeltaList := GetDeltas;
TServerMethods1Client.Create(dataModule2.DSRestConnection1).ApplyChanges(LDeltaList);
end;
浙公网安备 33010602011771号