private void ValidateMathematicalFunctionExpression(DbMathematicalFunctionExpression mathematicalFunctionExpression, DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType)
 {
     Assert.IsTrue(mathematicalFunctionExpression.ExpressionType == DbExpressionType.Function);
     Assert.IsTrue(mathematicalFunctionExpression.MathematicalFunctionExpressionType == mathematicalFunctionExpressionType);
     Assert.IsNotNull(mathematicalFunctionExpression.Arguments);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DbMathematicalFunctionExpression"/> class.
 /// </summary>
 /// <param name="mathematicalFunctionExpressionType">The <see cref="DbMathematicalFunctionExpressionType"/> of the <see cref="DbMathematicalFunctionExpression"/>.</param>
 /// <param name="arguments">The arguments used when calling the function.</param>
 internal DbMathematicalFunctionExpression(DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType, DbExpression[] arguments)
     : base(DbFunctionExpressionType.Mathematical, arguments)
 {
     MathematicalFunctionExpressionType = mathematicalFunctionExpressionType;
 }
Пример #3
0
        /// <summary>
        /// Returns the name of the function as it is defined in the target DBMS.
        /// </summary>
        /// <param name="mathematicalFunctionExpressionType">The <see cref="DbMathematicalFunctionExpressionType"/> that specifies the function name to return.</param>
        /// <returns><see cref="string"/></returns>
        protected virtual string GetMathematicalFunctionBody(DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType)
        {
            switch (mathematicalFunctionExpressionType)
            {
            case DbMathematicalFunctionExpressionType.Abs:
                return("ABS({0})");

            case DbMathematicalFunctionExpressionType.Acos:
                return("ACOS({0})");

            case DbMathematicalFunctionExpressionType.Asin:
                return("ASIN({0})");

            case DbMathematicalFunctionExpressionType.Atan:
                return("ATAN({0})");

            case DbMathematicalFunctionExpressionType.Atan2:
                return("ATAN2({0})");

            case DbMathematicalFunctionExpressionType.Ceiling:
                return("CEILING({0})");

            case DbMathematicalFunctionExpressionType.Cos:
                return("COS({0})");

            case DbMathematicalFunctionExpressionType.Cot:
                return("COT({0})");

            case DbMathematicalFunctionExpressionType.Degrees:
                return("DEGREES({0})");

            case DbMathematicalFunctionExpressionType.Exp:
                return("EXP({0})");

            case DbMathematicalFunctionExpressionType.Floor:
                return("FLOOR({0})");

            case DbMathematicalFunctionExpressionType.Log:
                return("LOG({0})");

            case DbMathematicalFunctionExpressionType.Log10:
                return("LOG10({0})");

            case DbMathematicalFunctionExpressionType.PI:
                return("PI()");

            case DbMathematicalFunctionExpressionType.Power:
                return("POWER({0})");

            case DbMathematicalFunctionExpressionType.Radians:
                return("RADIANS({0})");

            case DbMathematicalFunctionExpressionType.Rand:
                return("RAND()");

            case DbMathematicalFunctionExpressionType.RandSeed:
                return("RAND({0})");

            case DbMathematicalFunctionExpressionType.Round:
                return("ROUND({0})");

            case DbMathematicalFunctionExpressionType.Sign:
                return("SIGN({0})");

            case DbMathematicalFunctionExpressionType.Sin:
                return("SIN({0})");

            case DbMathematicalFunctionExpressionType.Sqrt:
                return("SQRT({0})");

            case DbMathematicalFunctionExpressionType.Square:
                return("SQUARE({0})");

            case DbMathematicalFunctionExpressionType.Tan:
                return("TAN({0})");

            default:
                throw new ArgumentOutOfRangeException("mathematicalFunctionExpressionType", mathematicalFunctionExpressionType, " is not supported");
            }
        }
 private void ValidateMathematicalFunctionExpression(DbMathematicalFunctionExpression mathematicalFunctionExpression, DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType)
 {
     Assert.IsTrue(mathematicalFunctionExpression.ExpressionType == DbExpressionType.Function);
     Assert.IsTrue(mathematicalFunctionExpression.MathematicalFunctionExpressionType == mathematicalFunctionExpressionType);
     Assert.IsNotNull(mathematicalFunctionExpression.Arguments);
 }
 /// <summary>
 /// Returns the name of the function as it is defined in the target DBMS.
 /// </summary>
 /// <param name="mathematicalFunctionExpressionType">The <see cref="DbMathematicalFunctionExpressionType"/> that specifies the function name to return.</param>
 /// <returns><see cref="string"/></returns>
 protected virtual string GetMathematicalFunctionBody(DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType)
 {
     switch (mathematicalFunctionExpressionType)
     {
         case DbMathematicalFunctionExpressionType.Abs:
             return "ABS({0})";
         case DbMathematicalFunctionExpressionType.Acos:
             return "ACOS({0})";
         case DbMathematicalFunctionExpressionType.Asin:
             return "ASIN({0})";
         case DbMathematicalFunctionExpressionType.Atan:
             return "ATAN({0})";
         case DbMathematicalFunctionExpressionType.Atan2:
             return "ATAN2({0})";
         case DbMathematicalFunctionExpressionType.Ceiling:
             return "CEIL({0})";
         case DbMathematicalFunctionExpressionType.Cos:
             return "COS({0})";
         case DbMathematicalFunctionExpressionType.Cot:
             return "COSH({0})";
         case DbMathematicalFunctionExpressionType.Degrees:
             return "DEGREES({0})";
         case DbMathematicalFunctionExpressionType.Exp:
             return "EXP({0})";
         case DbMathematicalFunctionExpressionType.Floor:
             return "FLOOR({0})";
         case DbMathematicalFunctionExpressionType.Log:
             return "LOG({0})";
         case DbMathematicalFunctionExpressionType.Log10:
             return "LOG(10,{0})";
         case DbMathematicalFunctionExpressionType.PI:
             return "ACOS(-1)";
         case DbMathematicalFunctionExpressionType.Power:
             return "POWER({0})";
         case DbMathematicalFunctionExpressionType.Radians:
             return "RADIANS({0})";
         case DbMathematicalFunctionExpressionType.Rand:
             return "dbms_random.value";
         case DbMathematicalFunctionExpressionType.RandSeed:
             return "RAND({0})";
         case DbMathematicalFunctionExpressionType.Round:
             return "ROUND({0})";
         case DbMathematicalFunctionExpressionType.Sign:
             return "SIGN({0})";
         case DbMathematicalFunctionExpressionType.Sin:
             return "SIN({0})";
         case DbMathematicalFunctionExpressionType.Sqrt:
             return "SQRT({0})";
         case DbMathematicalFunctionExpressionType.Tan:
             return "TAN({0})";
         default:
             throw new ArgumentOutOfRangeException("mathematicalFunctionExpressionType", mathematicalFunctionExpressionType, " is not supported");
     }
 }
 /// <summary>
 /// Creates a new <see cref="DbDateTimeFunctionExpression"/>.
 /// </summary>
 /// <param name="mathematicalFunctionExpressionType">The <see cref="DbMathematicalFunctionExpressionType"/> that specifies the type of <see cref="DbMathematicalFunctionExpression"/> to create.</param>
 /// <param name="arguments">A list of <see cref="DbExpression"/> instances that is used as arguments when calling the function.</param>
 /// <returns>A <see cref="DbMathematicalFunctionExpression"/> instance.</returns>
 public DbMathematicalFunctionExpression MakeMathematicalFunction(DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType, DbExpression[] arguments)
 {
     var mathematicalFunctionExpression = new DbMathematicalFunctionExpression(mathematicalFunctionExpressionType, arguments);
     return mathematicalFunctionExpression;
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbMathematicalFunctionExpression"/> class.
 /// </summary>
 /// <param name="mathematicalFunctionExpressionType">The <see cref="DbMathematicalFunctionExpressionType"/> of the <see cref="DbMathematicalFunctionExpression"/>.</param>
 /// <param name="arguments">The arguments used when calling the function.</param>
 internal DbMathematicalFunctionExpression(DbMathematicalFunctionExpressionType mathematicalFunctionExpressionType, DbExpression[] arguments)
     : base(DbFunctionExpressionType.Mathematical, arguments)
 {
     MathematicalFunctionExpressionType = mathematicalFunctionExpressionType;
 }