为lazarus TDataSet增加类似TClientDataSet的Delta功能
适用于所有TDataSet
只需在unit的uses添加DataSetDelta。
BufDataset1.ActivateMonitoring(true)//启动Delta功能
BufDataset1.GetActionSQL('test');//根据Delta生成SQL
继续开源:
https://github.com/szlbz/DataSetDelta.git
unit DataSetDelta; {$mode objfpc}{$H+} interface uses Classes, SysUtils, BufDataset, DB, TypInfo,Variants; type TDataStateValue = (dsvOriginal, dsvDeleted, dsvInserted, dsvUpdated); TDataSetChangesHelper =class Helper for TDataset public procedure createTable; function GetNewDataSet : TBufDataSet; function GetOldDataSet : TBufDataSet; function GetActionSQL(const ATableName : String; const AKeyFields: String = ''): String; function GetChangedCount:int64; procedure BeforeInserts(DataSet: TDataSet); procedure BeforeEdits(DataSet: TDataSet); procedure BeforeDeletes(DataSet:TDataSet); procedure AfterPosts(DataSet: TDataSet); procedure ActivateMonitoring(Value:Boolean); property ChangedCount:int64 read GetChangedCount; end; implementation
procedure TForm1.Button2Click(Sender: TObject); var sql:string; begin sql:=BufDataset1.GetActionSQL('test'); if sql<>'' then memo1.Lines.Add(sql); end; procedure TForm1.FormCreate(Sender: TObject); begin memo1.Lines.Clear; BufDataset1.ActivateMonitoring(true); end;
标签:function,DataSet,BufDataset1,lazarus,TClientDataSet,Delta,TDataSet,procedure From: https://www.cnblogs.com/qiufeng2014/p/18228518