-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpperFunction.cs
More file actions
61 lines (52 loc) · 1.68 KB
/
UpperFunction.cs
File metadata and controls
61 lines (52 loc) · 1.68 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
using System;
using Queries.Core.Parts.Columns;
using Queries.Core.Attributes;
namespace Queries.Core.Parts.Functions;
/// <summary>
/// "UPPER" function.
/// </summary>
[Function]
public class UpperFunction : IColumn, IAliasable<UpperFunction>
{
/// <summary>
/// Column onto wich the function applies
/// </summary>
public IColumn Column { get; }
/// <summary>
/// Alias of the result of the function
/// </summary>
public string Alias { get; private set; }
/// <summary>
/// Builds a new <see cref="UpperFunction"/> instance
/// </summary>
/// <param name="column">Column the function will be applied on</param>
/// <exception cref="ArgumentNullException">if <paramref name="column"/> is <code>null</code></exception>
public UpperFunction(IColumn column)
{
Column = column ?? throw new ArgumentNullException(nameof(column));
}
/// <summary>
/// Builds a new <see cref="UpperFunction"/> instance.
/// </summary>
/// <param name="value">the value the function will be applied on</param>
/// <exception cref="ArgumentNullException">if <paramref name="value"/> is <code>null</code></exception>
public UpperFunction(string value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
Column = value.Literal();
}
///<inheritdoc/>
public UpperFunction As(string alias)
{
Alias = alias;
return this;
}
/// <summary>
/// Performs a deep copy of the current instance.
/// </summary>
/// <returns><see cref="UpperFunction"/></returns>
public IColumn Clone() => new UpperFunction(Column.Clone());
}