Skip to content

Commit 005e62d

Browse files
committed
TimeOnly and DateOnly compilers use their own SqlDml.Extract()
1 parent 47eab77 commit 005e62d

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ internal static class DateOnlyCompilers
1919

2020
[Compiler(typeof(DateOnly), "Year", TargetKind.PropertyGet)]
2121
public static SqlExpression DateOnlyYear(SqlExpression _this) =>
22-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Year, _this));
22+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDatePart.Year, _this));
2323

2424
[Compiler(typeof(DateOnly), "Month", TargetKind.PropertyGet)]
2525
public static SqlExpression DateOnlyMonth(SqlExpression _this) =>
26-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Month, _this));
26+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDatePart.Month, _this));
2727

2828
[Compiler(typeof(DateOnly), "Day", TargetKind.PropertyGet)]
2929
public static SqlExpression DateOnlyDay(SqlExpression _this) =>
30-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Day, _this));
30+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDatePart.Day, _this));
3131

3232

3333
[Compiler(typeof(DateOnly), "DayOfYear", TargetKind.PropertyGet)]
3434
public static SqlExpression DateOnlyDayOfYear(SqlExpression _this)
3535
{
36-
return ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.DayOfYear, _this));
36+
return ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDatePart.DayOfYear, _this));
3737
}
3838

3939
[Compiler(typeof(DateOnly), "DayOfWeek", TargetKind.PropertyGet)]
4040
public static SqlExpression DateOnlyDayOfWeek(SqlExpression _this)
4141
{
42-
var baseExpression = ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.DayOfWeek, _this));
42+
var baseExpression = ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDatePart.DayOfWeek, _this));
4343
var context = ExpressionTranslationContext.Current;
4444
if (context == null) {
4545
return baseExpression;
@@ -137,15 +137,15 @@ public static SqlExpression DateOnlyToStringIso(SqlExpression _this)
137137
public static SqlExpression DateOnlyToStringIso(SqlExpression _this, [Type(typeof(string))] SqlExpression value)
138138
{
139139
throw new NotImplementedException();
140-
//var stringValue = value as SqlLiteral<string>;
140+
var stringValue = value as SqlLiteral<string>;
141141

142-
//if (stringValue == null)
143-
// throw new NotSupportedException(Strings.ExTranslationOfDateTimeToStringWithArbitraryArgumentsIsNotSupported);
142+
if (stringValue == null)
143+
throw new NotSupportedException(Strings.ExTranslationOfDateTimeToStringWithArbitraryArgumentsIsNotSupported);
144144

145-
//if (!stringValue.Value.Equals("s"))
146-
// throw new NotSupportedException(Strings.ExTranslationOfDateTimeToStringWithArbitraryArgumentsIsNotSupported);
145+
if (!stringValue.Value.Equals("s"))
146+
throw new NotSupportedException(Strings.ExTranslationOfDateTimeToStringWithArbitraryArgumentsIsNotSupported);
147147

148-
//return SqlDml.DateTimeToStringIso(_this);
148+
return SqlDml.DateTimeToStringIso(_this);
149149
}
150150
}
151151
#endif

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ internal static class TimeOnlyCompilers
2121

2222
[Compiler(typeof(TimeOnly), "Hour", TargetKind.PropertyGet)]
2323
public static SqlExpression TimeOnlyHour(SqlExpression _this) =>
24-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Hour, _this));
24+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlTimePart.Hour, _this));
2525

2626
[Compiler(typeof(TimeOnly), "Minute", TargetKind.PropertyGet)]
2727
public static SqlExpression TimeOnlyMinute(SqlExpression _this) =>
28-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Minute, _this));
28+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlTimePart.Minute, _this));
2929

3030
[Compiler(typeof(TimeOnly), "Second", TargetKind.PropertyGet)]
3131
public static SqlExpression TimeOnlySecond(SqlExpression _this) =>
32-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Second, _this));
32+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlTimePart.Second, _this));
3333

3434
[Compiler(typeof(TimeOnly), "Millisecond", TargetKind.PropertyGet)]
3535
public static SqlExpression TimeOnlyMillisecond(SqlExpression _this) =>
36-
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Millisecond, _this));
36+
ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlTimePart.Millisecond, _this));
3737

3838
[Compiler(typeof(TimeOnly), "Ticks", TargetKind.PropertyGet)]
3939
public static SqlExpression TimeOnlyTicks(SqlExpression _this)

0 commit comments

Comments
 (0)