Ejemplo n.º 1
0
 public static SqlExpression DateTimeAddMonths(SqlExpression _this,
                                               [Type(typeof(int))] SqlExpression value)
 {
     return(SqlDml.DateTimeAddMonths(_this, value));
 }
Ejemplo n.º 2
0
 private static SqlExpression DateTimeOffsetTruncate(SqlExpression dateTimeOffset) =>
 SqlDml.Cast(
     SqlDml.Cast(dateTimeOffset, new SqlValueType(SqlDateTypeName)),
     new SqlValueType(SqlDateTime2TypeName));
Ejemplo n.º 3
0
 private static SqlExpression DateTimeOffsetPartOffset(SqlExpression dateTimeOffset) =>
 SqlDml.DateTimeOffsetMinusDateTimeOffset(
     DateTimeOffsetTruncateOffset(dateTimeOffset),
     Switchoffset(dateTimeOffset, UtcTimeZone));
Ejemplo n.º 4
0
 protected static SqlUserFunctionCall DateAddSecond(SqlExpression date, SqlExpression seconds)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("SECOND"), seconds, date));
 }
Ejemplo n.º 5
0
 protected static SqlUserFunctionCall BitXor(SqlExpression left, SqlExpression right)
 {
     return(SqlDml.FunctionCall("BIN_XOR", left, right));
 }
Ejemplo n.º 6
0
 protected static SqlUserFunctionCall DateAddMonth(SqlExpression date, SqlExpression months)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MONTH"), months, date));
 }
Ejemplo n.º 7
0
 protected static SqlUserFunctionCall DateAddHour(SqlExpression date, SqlExpression hours)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("HOUR"), hours, date));
 }
Ejemplo n.º 8
0
 public static SqlExpression DateTimeMillisecond(SqlExpression _this)
 {
     return(ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.Millisecond, _this)));
 }
Ejemplo n.º 9
0
 public static SqlExpression DateTimeTimeOfDay(SqlExpression _this)
 {
     return(SqlDml.DateTimeMinusDateTime(_this, SqlDml.DateTimeTruncate(_this)));
 }
Ejemplo n.º 10
0
 public static SqlExpression DateTimeNow()
 {
     return(SqlDml.CurrentTimeStamp());
 }
Ejemplo n.º 11
0
 public static SqlExpression DateTimeToday()
 {
     return(SqlDml.CurrentDate());
 }
Ejemplo n.º 12
0
 public static SqlExpression DateTimeSubtractDateTime(SqlExpression _this,
                                                      [Type(typeof(DateTime))] SqlExpression value)
 {
     return(SqlDml.DateTimeMinusDateTime(_this, value));
 }
Ejemplo n.º 13
0
 public static SqlExpression DateTimeSubtractTimeSpan(SqlExpression _this,
                                                      [Type(typeof(TimeSpan))] SqlExpression value)
 {
     return(SqlDml.DateTimeMinusInterval(_this, value));
 }
Ejemplo n.º 14
0
 public static SqlExpression DateTimeAddMilliseconds(SqlExpression _this,
                                                     [Type(typeof(double))] SqlExpression value)
 {
     return(SqlDml.DateTimePlusInterval(_this, TimeSpanCompilers.TimeSpanFromMilliseconds(value)));
 }
Ejemplo n.º 15
0
 protected static SqlUserFunctionCall DateDiffMillisecond(SqlExpression date1, SqlExpression date2)
 {
     return(SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("MILLISECOND"), date1, date2));
 }
Ejemplo n.º 16
0
 public static SqlExpression DateTimeDate(SqlExpression _this)
 {
     return(SqlDml.DateTimeTruncate(_this));
 }
Ejemplo n.º 17
0
 protected static SqlUserFunctionCall DateAddYear(SqlExpression date, SqlExpression years)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("YEAR"), years, date));
 }
Ejemplo n.º 18
0
 public static SqlExpression DateTimeDayOfYear(SqlExpression _this)
 {
     return(ExpressionTranslationHelpers.ToInt(SqlDml.Extract(SqlDateTimePart.DayOfYear, _this)));
 }
Ejemplo n.º 19
0
 protected static SqlUserFunctionCall DateAddDay(SqlExpression date, SqlExpression days)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("DAY"), days, date));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 21
0
 protected static SqlUserFunctionCall DateAddMinute(SqlExpression date, SqlExpression minutes)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MINUTE"), minutes, date));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 23
0
 protected static SqlUserFunctionCall DateAddMillisecond(SqlExpression date, SqlExpression milliseconds)
 {
     return(SqlDml.FunctionCall("DATEADD", SqlDml.Native("MILLISECOND"), milliseconds, date));
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 25
0
 protected static SqlUserFunctionCall BitNot(SqlExpression operand)
 {
     return(SqlDml.FunctionCall("BIN_NOT", operand));
 }
Ejemplo n.º 26
0
 protected static SqlCast CastToLong(SqlExpression arg)
 {
     return(SqlDml.Cast(arg, SqlType.Int64));
 }
Ejemplo n.º 27
0
 private static SqlExpression DateTimeOffsetTruncateOffset(SqlExpression dateTimeOffset) =>
 SqlDml.Cast(dateTimeOffset, SqlType.DateTime);
Ejemplo n.º 28
0
 protected static SqlUserFunctionCall DateDiffDay(SqlExpression date1, SqlExpression date2)
 {
     return(SqlDml.FunctionCall("DATEDIFF", SqlDml.Native("DAY"), date1, date2));
 }
Ejemplo n.º 29
0
 private static SqlExpression DateTimeOffsetTimeOfDay(SqlExpression dateTimeOffset) =>
 DateDiffMillisecond(
     SqlDml.Native("'00:00:00.0000000'"),
     SqlDml.Cast(dateTimeOffset, new SqlValueType("time")))
 * NanosecondsPerMillisecond;
Ejemplo n.º 30
0
 public static SqlExpression DateTimeOperatorSubtractionDateTime(
     [Type(typeof(DateTime))] SqlExpression d1,
     [Type(typeof(DateTime))] SqlExpression d2)
 {
     return(SqlDml.DateTimeMinusDateTime(d1, d2));
 }