-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathSystem.Query.Fluent.pas
More file actions
70 lines (57 loc) · 1.49 KB
/
System.Query.Fluent.pas
File metadata and controls
70 lines (57 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
unit System.Query.Fluent;
interface
uses System.Classes, System.SysUtils, Data.DB;
type
IFluentQuery = Interface
['{738FDA90-A6E8-4FB0-A65E-6FCD4DF79F4E}']
Function Dataset(ADataset: TDataset):IFluentQuery;overload;
Function Dataset():TDataset;overload;
function Where(AWhere:String):IFluentQuery;
End;
TFluentQueryAttrib = record
Fields:string;
Table:String;
Where:String;
Join:string;
GroupBy:string;
OrderBy:String;
end;
TFluentQuery<T: Class> = class(TInterfacedObject, IFluentQuery)
protected
FDataset: TDataset;
FAttrib:TFluentQueryAttrib;
public
class function QueryBuilder(AAttrib:TFluentQueryAttrib):string;static;
class function New: IFluentQuery; static;
function Dataset(ADataset: TDataset): IFluentQuery;overload;
Function Dataset():TDataset;overload;
function Where(AWhere:String):IFluentQuery;
end;
implementation
uses System.Rtti;
function TFluentQuery<T>.Dataset: TDataset;
begin
result := FDataset;
end;
class function TFluentQuery<T>.New: IFluentQuery;
var
q: TFluentQuery<T>;
begin
q := TFluentQuery<T>.create;
q.Dataset(TDataset(T).create(nil));
result := q;
end;
class function TFluentQuery<T>.QueryBuilder(
AAttrib: TFluentQueryAttrib): string;
begin
end;
function TFluentQuery<T>.Where(AWhere: String): IFluentQuery;
begin
FAttrib.Where := AWhere;
end;
function TFluentQuery<T>.Dataset(ADataset: TDataset): IFluentQuery;
begin
FDataset := ADataset;
result := self;
end;
end.