Skip to content

Commit c5b26ca

Browse files
committed
SqlDml : add TimeConstruct method with ticks as parameter
and use it in TimeOnlyCompilers
1 parent ff7c10c commit c5b26ca

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

Orm/Xtensive.Orm/Orm/Providers/Expressions/MemberCompilers/TimeOnlyCompilers.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ public static SqlExpression TimeOnlyCtor(
5959
[Type(typeof(int))] SqlExpression minute) =>
6060
SqlDml.TimeConstruct(hour, minute, 0, 0);
6161

62-
//[Compiler(typeof(TimeOnly), null, TargetKind.Constructor)]
63-
//public static SqlExpression TimeOnlyCtor([Type(typeof(long))] SqlExpression ticks) =>
64-
// new SqlFunctionCall(SqlFunctionType.TimeConstruct, ticks);
62+
[Compiler(typeof(TimeOnly), null, TargetKind.Constructor)]
63+
public static SqlExpression TimeOnlyCtor([Type(typeof(long))] SqlExpression ticks) =>
64+
SqlDml.TimeConstruct(ticks);
6565

6666
#endregion
6767

Orm/Xtensive.Orm/Sql/SqlDml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,16 @@ public static SqlFunctionCall TimeConstruct(SqlExpression hour,
614614
SqlValidator.EnsureIsArithmeticExpression(second);
615615
SqlValidator.EnsureIsArithmeticExpression(millisecond);
616616

617-
//var m = milliseconds + 1000L * (seconds + 60L * (minutes + 60L * hours));
618-
//var ticks = 10_000 * m;
619617
return new SqlFunctionCall(SqlFunctionType.TimeConstruct, hour, minute, second, millisecond);
620618
}
619+
620+
public static SqlFunctionCall TimeConstruct(SqlExpression ticks)
621+
{
622+
ArgumentNullException.ThrowIfNull(ticks);
623+
SqlValidator.EnsureIsArithmeticExpression(ticks);
624+
625+
return new SqlFunctionCall(SqlFunctionType.TimeConstruct, ticks);
626+
}
621627
#endif
622628

623629
public static SqlBinary DateTimePlusInterval(SqlExpression left, SqlExpression right)

0 commit comments

Comments
 (0)