-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLengthFunction.cs
More file actions
51 lines (44 loc) · 1.43 KB
/
LengthFunction.cs
File metadata and controls
51 lines (44 loc) · 1.43 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
using Queries.Core.Attributes;
using Queries.Core.Parts.Columns;
using System;
namespace Queries.Core.Parts.Functions;
/// <summary>
/// Function that computes the length of a column
/// </summary>
[Function]
public class LengthFunction : IAliasable<LengthFunction>, IColumn
{
/// <summary>
/// The column onto which <see cref="LengthFunction"/> will be applied
/// </summary>
public IColumn Column { get; }
private string _alias;
/// <summary>
/// Alias sets for the function.
/// </summary>
public string Alias => _alias;
/// <summary>
/// Builds a new <see cref="LengthFunction"/> instance.
/// </summary>
/// <param name="column">The column onto which the function must be applied.</param>
/// <exception cref="ArgumentNullException">if <paramref name="column"/> is <c>nulll</c></exception>
public LengthFunction(IColumn column)
{
Column = column ?? throw new ArgumentNullException(nameof(column));
}
/// <summary>
/// Set the alias of the function
/// </summary>
/// <param name="alias"></param>
/// <returns>The current instance</returns>
public LengthFunction As(string alias)
{
_alias = alias;
return this;
}
/// <summary>
/// Performs a deep copy of the current instance.
/// </summary>
/// <returns><see cref="LengthFunction"/></returns>
public IColumn Clone() => new LengthFunction(Column.Clone());
}