-
-
Notifications
You must be signed in to change notification settings - Fork 524
Expand file tree
/
Copy pathColumnClause.cs
More file actions
130 lines (122 loc) · 3.51 KB
/
ColumnClause.cs
File metadata and controls
130 lines (122 loc) · 3.51 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
namespace SqlKata
{
public abstract class AbstractColumn : AbstractClause
{
}
/// <summary>
/// Represents "column" or "column as alias" clause.
/// </summary>
/// <seealso cref="AbstractColumn" />
public class Column : AbstractColumn
{
/// <summary>
/// Gets or sets the column name. Can be "columnName" or "columnName as columnAlias".
/// </summary>
/// <value>
/// The column name.
/// </value>
public string Name { get; set; }
/// <inheritdoc />
public override AbstractClause Clone()
{
return new Column
{
Engine = Engine,
Name = Name,
Component = Component,
};
}
}
/// <summary>
/// Represents date column clause calculated using query.
/// </summary>
public class DateQueryColumn : Column
{
public string Column { get; set; }
public string Part { get; set; }
public override AbstractClause Clone()
{
return new DateQueryColumn
{
Engine = Engine,
Name=Name,
Column = Column,
Component = Component,
Part = Part,
};
}
}
/// <summary>
/// Represents column clause calculated using query.
/// </summary>
/// <seealso cref="AbstractColumn" />
public class QueryColumn : AbstractColumn
{
/// <summary>
/// Gets or sets the query that will be used for column value calculation.
/// </summary>
/// <value>
/// The query for column value calculation.
/// </value>
public Query Query { get; set; }
public override AbstractClause Clone()
{
return new QueryColumn
{
Engine = Engine,
Query = Query.Clone(),
Component = Component,
};
}
}
public class RawColumn : AbstractColumn
{
/// <summary>
/// Gets or sets the RAW expression.
/// </summary>
/// <value>
/// The RAW expression.
/// </value>
public string Expression { get; set; }
public object[] Bindings { set; get; }
/// <inheritdoc />
public override AbstractClause Clone()
{
return new RawColumn
{
Engine = Engine,
Expression = Expression,
Bindings = Bindings,
Component = Component,
};
}
}
/// <summary>
/// Represents an aggregated column clause with an optional filter
/// </summary>
/// <seealso cref="AbstractColumn" />
public class AggregatedColumn : AbstractColumn
{
/// <summary>
/// Gets or sets the a query that used to filter the data,
/// the compiler will consider only the `Where` clause.
/// </summary>
/// <value>
/// The filter query.
/// </value>
public Query Filter { get; set; } = null;
public string Aggregate { get; set; }
public AbstractColumn Column { get; set; }
public override AbstractClause Clone()
{
return new AggregatedColumn
{
Engine = Engine,
Filter = Filter?.Clone(),
Column = Column.Clone() as AbstractColumn,
Aggregate = Aggregate,
Component = Component,
};
}
}
}