예제 #1
0
        /// <summary>
        /// Performs banker's rounding on the specified argument.
        /// </summary>
        /// <param name="value">The value to round.</param>
        /// <returns>Result of rounding.</returns>
        public static SqlExpression BankersRound(SqlExpression value)
        {
            var mainPart  = 2 * SqlDml.Floor((value + 0.5) / 2);
            var extraPart = SqlDml.Case();

            extraPart.Add(value - mainPart > 0.5, 1);
            extraPart.Else = 0;
            return(mainPart + extraPart);
        }
예제 #2
0
 public static SqlExpression MathFloorDouble(
     [Type(typeof(double))] SqlExpression d)
 {
     return(SqlDml.Floor(d));
 }
예제 #3
0
 public static SqlExpression MathFloorDecimal(
     [Type(typeof(decimal))] SqlExpression d)
 {
     return(SqlDml.Floor(d));
 }
예제 #4
0
 public static SqlExpression MathFloorDecimal(
     [Type(typeof(decimal))] SqlExpression d)
 {
     return(TryCastToDecimalPS(SqlDml.Floor(d), 28, 0));
 }