-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCurrentMomentFunction.cs
More file actions
35 lines (28 loc) · 1.35 KB
/
Copy pathCurrentMomentFunction.cs
File metadata and controls
35 lines (28 loc) · 1.35 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
using TeamTools.TSQL.ExpressionEvaluator.BuiltInFunctions.ArgumentDto;
using TeamTools.TSQL.ExpressionEvaluator.TypeHandling;
using TeamTools.TSQL.ExpressionEvaluator.Values;
namespace TeamTools.TSQL.ExpressionEvaluator.BuiltInFunctions.Abstractions
{
public abstract class CurrentMomentFunction<TOut> : SqlZeroArgFunctionHandler
where TOut : SqlValue
{
private readonly TimeDetails timeDetails;
private readonly DateDetails dateDetails;
protected CurrentMomentFunction(string funcName, string outputType, TimeDetails timeDetails, DateDetails dateDetails) : base(funcName, outputType)
{
this.timeDetails = timeDetails;
this.dateDetails = dateDetails;
}
protected override SqlValue DoEvaluateResultValue(CallSignature<ZeroArgs> call)
{
var value = call.Context.Converter.ImplicitlyConvert<TOut>(base.DoEvaluateResultValue(call));
if (value is null)
{
return default;
}
var newRange = new SqlDateTimeValueRange(new SqlDateTimeRelativeValue(DateTimeRangeKind.CurrentMoment, timeDetails, dateDetails));
return ApplyNewRange(value, newRange, call.Context.NewSource);
}
protected abstract TOut ApplyNewRange(TOut value, SqlDateTimeValueRange newRange, SqlValueSource src);
}
}