Beispiel #1
0
 public static SqlExpression DateTimeAddMonths(SqlExpression _this,
                                               [Type(typeof(int))] SqlExpression value)
 {
     return(SqlDml.DateTimeAddMonths(_this, value));
 }
Beispiel #2
0
 private static SqlExpression DateTimeOffsetTruncate(SqlExpression dateTimeOffset) =>
 SqlDml.Cast(
     SqlDml.Cast(dateTimeOffset, new SqlValueType(SqlDateTypeName)),
     new SqlValueType(SqlDateTime2TypeName));
Beispiel #3
0
 private static SqlExpression DateTimeOffsetPartOffset(SqlExpression dateTimeOffset) =>
 SqlDml.DateTimeOffsetMinusDateTimeOffset(
     DateTimeOffsetTruncateOffset(dateTimeOffset),
     Switchoffset(dateTimeOffset, UtcTimeZone));
Beispiel #4
0
 protected static SqlUserFunctionCall DateAddSecond(SqlExpression date, SqlExpression seconds)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("SECOND"), seconds, date));
 }
Beispiel #5
0
 protected static SqlUserFunctionCall BitXor(SqlExpression left, SqlExpression right)
 {
     return(SqlDml.FunctionCall("BIN_XOR", left, right));
 }
Beispiel #6
0
 protected static SqlUserFunctionCall DateAddMonth(SqlExpression date, SqlExpression months)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MONTH"), months, date));
 }
Beispiel #7
0
 protected static SqlUserFunctionCall DateAddHour(SqlExpression date, SqlExpression hours)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("HOUR"), hours, date));
 }
Beispiel #8
0
 public static SqlExpression DateTimeMillisecond(SqlExpression _this)
 {
     return(ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Millisecond, _this)));
 }
Beispiel #9
0
 public static SqlExpression DateTimeTimeOfDay(SqlExpression _this)
 {
     return(SqlDml.DateTimeMinusDateTime(_this, SqlDml.DateTimeTruncate(_this)));
 }
Beispiel #10
0
 public static SqlExpression DateTimeNow()
 {
     return(SqlDml.CurrentTimeStamp());
 }
Beispiel #11
0
 public static SqlExpression DateTimeToday()
 {
     return(SqlDml.CurrentDate());
 }
Beispiel #12
0
 public static SqlExpression DateTimeSubtractDateTime(SqlExpression _this,
                                                      [Type(typeof(DateTime))] SqlExpression value)
 {
     return(SqlDml.DateTimeMinusDateTime(_this, value));
 }
Beispiel #13
0
 public static SqlExpression DateTimeSubtractTimeSpan(SqlExpression _this,
                                                      [Type(typeof(TimeSpan))] SqlExpression value)
 {
     return(SqlDml.DateTimeMinusInterval(_this, value));
 }
Beispiel #14
0
 public static SqlExpression DateTimeAddMilliseconds(SqlExpression _this,
                                                     [Type(typeof(double))] SqlExpression value)
 {
     return(SqlDml.DateTimePlusInterval(_this, TimeSpanCompilers.TimeSpanFromMilliseconds(value)));
 }
Beispiel #15
0
 protected static SqlUserFunctionCall DateDiffMillisecond(SqlExpression date1, SqlExpression date2)
 {
     return(SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("MILLISECOND"), date1, date2));
 }
Beispiel #16
0
 public static SqlExpression DateTimeDate(SqlExpression _this)
 {
     return(SqlDml.DateTimeTruncate(_this));
 }
Beispiel #17
0
 protected static SqlUserFunctionCall DateAddYear(SqlExpression date, SqlExpression years)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("YEAR"), years, date));
 }
Beispiel #18
0
 public static SqlExpression DateTimeDayOfYear(SqlExpression _this)
 {
     return(ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.DayOfYear, _this)));
 }
Beispiel #19
0
 protected static SqlUserFunctionCall DateAddDay(SqlExpression date, SqlExpression days)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("DAY"), days, date));
 }
Beispiel #20
0
        /// <summary>
        /// Converts the specified interval expression to expression
        /// that represents number of milliseconds in that interval.
        /// This is a generic implementation via <see cref="SqlExtract"/>s.
        /// It's suitable for any server, but can be inefficient.
        /// </summary>
        /// <param name="interval">The interval to convert.</param>
        /// <returns>Result of conversion.</returns>
        public static SqlExpression IntervalToNanoseconds(SqlExpression interval)
        {
            var nanoseconds = SqlDml.Extract(SqlIntervalPart.Nanosecond, interval);

            return(IntervalToMilliseconds(interval) * 1000000L + nanoseconds);
        }
Beispiel #21
0
 protected static SqlUserFunctionCall DateAddMinute(SqlExpression date, SqlExpression minutes)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MINUTE"), minutes, date));
 }
Beispiel #22
0
        /// <summary>
        /// Performs banker's rounding on the speicified argument
        /// to a specified number of fractional digits.
        /// </summary>
        /// <param name="value">The value to round.</param>
        /// <param name="digits">The digits.</param>
        /// <returns>Result of rounding.</returns>
        public static SqlExpression BankersRound(SqlExpression value, SqlExpression digits)
        {
            var scale = SqlDml.Power(10, digits);

            return(BankersRound(value * scale) / scale);
        }
Beispiel #23
0
 protected static SqlUserFunctionCall DateAddMillisecond(SqlExpression date, SqlExpression milliseconds)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MILLISECOND"), milliseconds, date));
 }
Beispiel #24
0
        /// <summary>
        /// Performs "rounding as tought in school" on the specified argument
        /// to a specified number of fractional digits.
        /// </summary>
        /// <param name="argument">The value to round.</param>
        /// <param name="digits">The digits.</param>
        /// <returns>Result of rounding.</returns>
        public static SqlExpression RegularRound(SqlExpression argument, SqlExpression digits)
        {
            var scale = SqlDml.Power(10, digits);

            return(RegularRound(argument * scale) / scale);
        }
Beispiel #25
0
 protected static SqlUserFunctionCall BitNot(SqlExpression operand)
 {
     return(SqlDml.FunctionCall("BIN_NOT", operand));
 }
Beispiel #26
0
 protected static SqlCast CastToLong(SqlExpression arg)
 {
     return(SqlDml.Cast(arg, SqlType.Int64));
 }
Beispiel #27
0
 private static SqlExpression DateTimeOffsetTruncateOffset(SqlExpression dateTimeOffset) =>
 SqlDml.Cast(dateTimeOffset, SqlType.DateTime);
Beispiel #28
0
 protected static SqlUserFunctionCall DateDiffDay(SqlExpression date1, SqlExpression date2)
 {
     return(SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("DAY"), date1, date2));
 }
Beispiel #29
0
 private static SqlExpression DateTimeOffsetTimeOfDay(SqlExpression dateTimeOffset) =>
 DateDiffMillisecond(
     SqlDml.Native("'00:00:00.0000000'"),
     SqlDml.Cast(dateTimeOffset, new SqlValueType("time")))
 * NanosecondsPerMillisecond;
Beispiel #30
0
 public static SqlExpression DateTimeOperatorSubtractionDateTime(
     [Type(typeof(DateTime))] SqlExpression d1,
     [Type(typeof(DateTime))] SqlExpression d2)
 {
     return(SqlDml.DateTimeMinusDateTime(d1, d2));
 }