类别 | 说明 |
TFDJSONDatasets | FireDAC使用JSONDataSet,其中可包括多个DataSet对象 |
TFDJSONDataSetsWriter | 把TDataSet写入TFDJSONDatasets |
TFDJSONDatasetsReader | 读取TdataSet从TFDJSONDatasets |
TFDJSONIntercaptor | TFDJSONDatasets和json质检进行转换 |
class procedure ListAdd(const ADataKist :TFDJSONDataSets; const AName : string;const ADataSet : TFDAdaptedDataSet ) ; overload; class procedure ListAdd(const ADataKist :TFDJSONDataSets; const ADataSet : TFDAdaptedDataSet ) ; overload
class function FetListValue(const ADataList : TFDJSONDataSets; i : Integer) : TFDAdaptedDataSet; static; class function FetListValueByName(const ADataList : TFDJSONDataSets; const AName : string) : TFDAdaptedDataSet; static;
把上面看明白,那么手动写个程序就简单了。
1、服务器端方法:
function TServerMethods1.GetADataset(const ASQL : string): TFDJSONDataSets; begin //首先从服务器get数据集 fdquery1.SQL.clear; fdquery1.SQL.Add(ASQL); Result := TFDJSONDataSets.Create; TFDJSONDataSetsWriter.ListAdd(Result,fdquery1); end;
2、在客户端连接组件TDSRestConnection右击生成客户端代码Generate DataSnap Client classes
3、客户端调用
var aServer : TServerMethodsClient; LDataSetList : TFDJSONDataSets; aDataset : TFDAdaptedDataset; begin aServer := Nil; AServer := TServerMethodsClient.Create(dmRESTfulClient.DSRestConnection1); LDataSetList := aServer.GetADataset('select * fro t1'); fdmtable.appendData(LDataSetList); end;