-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHavingClause.cs
More file actions
85 lines (73 loc) · 2.8 KB
/
HavingClause.cs
File metadata and controls
85 lines (73 loc) · 2.8 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
using Queries.Core.Parts.Columns;
using Queries.Core.Parts.Functions;
using System;
namespace Queries.Core.Parts.Clauses;
/// <summary>
/// Constraint to apply to an <see cref="AggregateFunction"/>
/// </summary>
public class HavingClause : IHavingClause, IClause<AggregateFunction>, IEquatable<HavingClause>
{
/// <summary>
/// Column the clause will be applied onto
/// </summary>
public AggregateFunction Column { get; }
/// <summary>
/// Operator to apply beetwen <see cref="Column"/> and <see cref="Constraint"/>.
/// </summary>
public ClauseOperator Operator { get; }
/// <summary>
/// Constraint to apply
/// </summary>
public IColumn Constraint { get; }
/// <summary>
/// Builds a new <see cref="HavingClause"/> instance.
/// </summary>
/// <param name="column">column the </param>
/// <param name="operator"></param>
/// <param name="constraint"></param>
public HavingClause(AggregateFunction column, ClauseOperator @operator, IColumn constraint = null)
{
Column = column ?? throw new ArgumentNullException(nameof(column));
Operator = @operator;
Constraint = constraint;
}
/// <summary>
/// Builds a new <see cref="HavingClause"/> instance.
/// </summary>
/// <param name="column"></param>
/// <param name="operator"></param>
/// <param name="constraint"></param>
public HavingClause(AggregateFunction column, ClauseOperator @operator, string constraint)
: this(column, @operator, constraint?.Literal())
{
}
/// <summary>
/// Builds a new <see cref="HavingClause"/> instance.
/// </summary>
/// <param name="column"></param>
/// <param name="operator"></param>
/// <param name="constraint"></param>
public HavingClause(AggregateFunction column, ClauseOperator @operator, long? constraint)
: this(column, @operator, constraint?.Literal())
{
}
/// <summary>
/// Builds a new <see cref="HavingClause"/> instance.
/// </summary>
/// <param name="column"></param>
/// <param name="operator"></param>
/// <param name="constraint"></param>
public HavingClause(AggregateFunction column, ClauseOperator @operator, bool? constraint)
: this(column, @operator, constraint?.Literal())
{
}
///<inheritdoc/>
public IHavingClause Clone() => new HavingClause(Column, Operator, Constraint);
///<inheritdoc/>
public override bool Equals(object obj) => Equals(obj as HavingClause);
///<inheritdoc/>
public bool Equals(HavingClause other) => other is not null
&& (Column, Operator, Constraint).Equals((other.Column, other.Operator, other.Constraint));
///<inheritdoc/>
public override int GetHashCode() => (Column, Operator, Constraint).GetHashCode();
}