Firedac's Tfdjsondatasets and Tfdjsondeltas

Source: Internet
Author: User
Tags constant definition

A) server-side code demo
1) Constant definition:
Const ' Department '; ' Employees ';

2) query data:

function TServerMethods1.Getdepartmentemployees(Const AID:String): Tfdjsondatasets;BeginClear active So, query would reexecute. Fdquerydepartmentemployees.Active:=False; Fdquerydepartment.Active:=False; Fdquerydepartment.Params[0].Value:= AID; Fdquerydepartmentemployees.Params[0].value := aid;  // Create DataSet list Result := tfdjsondatasets. Create//ADD departments DataSet Tfdjsondatasetswriter. Listadd//ADD employees DataSet Tfdjsondatasetswriter. Listadd ; End              
The TFDJSONDATASETS,FIREDAC DataSet list object, which returns multiple datasets.

3) Submit data:
Procedure TServerMethods1.Applychangesdepartmentemployees(Const ADELTALIST: Tfdjsondeltas);var lapply: ifdjsondeltasapplyupdates;BeginCreate the Apply Object lapply:= Tfdjsondeltasapplyupdates.Create(adeltalist);Apply the Department Delta Lapply.Applyupdates(sdepartment, fdquerydepartment.Command);If lapply.Errors.Count=0ThenIf no errors, apply the employee Delta Lapply. applyupdates(semployees, Fdquerydepartmentemployees.  Command); if lapply.  Errors.  Count > 0 then //Raise A exception if any errors. raise Exception.  Create(lapply.  Errors.  Strings.  Text);  End;

II) client Demo code
1) query data:
Procedure TForm2.Getdepartmentemployees(Const ADEPTNO:String);var ldatasetlist: Tfdjsondatasets; Ldataset: Tfddataset;Begin Ldatasetlist:= ClientModule1.Servermethods1client.Getdepartmentemployees(Adeptno);Get Department DataSet Ldataset:= Tfdjsondatasetsreader.Getlistvaluebyname(ldatasetlist, sdepartment);Update UI fdmemtabledepartment.Active:=False; Fdmemtabledepartment.   AppendData(Ldataset); //Get Employees DataSet Ldataset := Tfdjsondatasetsreader.  Getlistvaluebyname(ldatasetlist, semployees); //Update UI fdmemtableemployee.  Active := False; Fdmemtableemployee.  AppendData(Ldataset);  End;
2) Submit data:
function TForm2.Getdeltas: Tfdjsondeltas;BeginPost if editingIf fdmemtabledepartment.StateIn DseditmodesThenBegin Fdmemtabledepartment.Post;End;If Fdmemtableemployee.StateIn DseditmodesThenbegin Fdmemtableemployee.  Post;  End; //Create a delta list Result := Tfdjsondeltas.  Create; //Add deltas Tfdjsondeltaswriter.  Listadd(Result, Semployees, Fdmemtableemployee); Tfdjsondeltaswriter.  Listadd(Result, sdepartment, fdmemtabledepartment);  End;                  


Procedure TForm2.  Applyupdates;  var  ldeltalist: Tfdjsondeltas;:= Getdeltas//Call server method. Pass the Delta list. ClientModule1.  Servermethods1client.  Applychangesdepartmentemployees(ldeltalist); end;                 

Attention:
There are 2 controls to be placed on both the server and the client:
Tfdstanstoragejsonlink
Tfdstanstoragebinlink


       
              

Firedac Tfdjsondatasets and Tfdjsondeltas

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.