Example #1
0
        /// <summary>
        /// <para>ROUND built-in function.</para>
        /// <para>Returns a numeric value, rounded to the specified length or precision.</para>
        /// </summary>
        /// <param name="argument">Is an expression of the exact numeric or approximate numeric data type category, except for the bit data type.</param>
        /// <param name="length">Is the precision to which the argument is to be rounded. length must be an expression of type tinyint, smallint, or int.</param>
        /// <param name="function">Is the type of operation to perform. function must be tinyint, smallint, or int. When function is omitted or has a value of 0 (default), the argument is rounded.</param>
        public static SysFn Round(NumericArgument argument, NumericArgument length, NumericArgument function)
        {
            if (argument == null)
            {
                argument = Designer.Null;
            }
            if (length == null)
            {
                length = Designer.Null;
            }
            if (function == null)
            {
                function = Designer.Null;
            }

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "ROUND({0},{1},{2})",
                    argument.Build(buildContext, buildArgs),
                    length.Build(buildContext, buildArgs),
                    function.Build(buildContext, buildArgs));
                buildContext.TryTakeException(argument.Exception, "Sys.Round");
                buildContext.TryTakeException(length.Exception, "Sys.Round");
                buildContext.TryTakeException(function.Exception, "Sys.Round");
                return sql;
            }));
        }
Example #2
0
        /// <summary>
        /// <para>ATAN built-in function.</para>
        /// <para>Returns the angle in radians whose tangent is a specified float expression. This is also called arctangent.</para>
        /// </summary>
        /// <param name="argument">Is an expression of the type float or of a type that can be implicitly converted to float.</param>
        public static SysFn Atan(NumericArgument argument)
        {
            argument = argument ?? Designer.Null;

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "ATAN({0})",
                    argument.Build(buildContext, buildArgs));
                buildContext.TryTakeException(argument.Exception, "Sys.Atan");
                return sql;
            }));
        }
Example #3
0
        /// <summary>
        /// <para>RAND built-in function.</para>
        /// <para>Returns a pseudo-random float value from 0 through 1, exclusive.</para>
        /// </summary>
        /// <param name="seed">Is an integer expression (tinyint, smallint, or int) that gives the seed value. If seed is not specified, the SQL Server Database Engine assigns a seed value at random. For a specified seed value, the result returned is always the same.</param>
        public static SysFn Rand(NumericArgument seed)
        {
            seed = seed ?? Designer.Null;

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "RAND({0})",
                    seed.Build(buildContext, buildArgs));
                buildContext.TryTakeException(seed.Exception, "Sys.Rand");
                return sql;
            }));
        }
Example #4
0
        /// <summary>
        /// <para>ATN2 built-in function.</para>
        /// <para>Returns the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x), where x and y are the values of the two specified float expressions.</para>
        /// </summary>
        /// <param name="argument1">Is an expression of the float data type.</param>
        /// <param name="argument2">Is an expression of the float data type.</param>
        public static SysFn Atn2(NumericArgument argument1, NumericArgument argument2)
        {
            if (argument1 == null)
            {
                argument1 = Designer.Null;
            }
            if (argument2 == null)
            {
                argument2 = Designer.Null;
            }

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "ATN2({0},{1})",
                    argument1.Build(buildContext, buildArgs),
                    argument2.Build(buildContext, buildArgs));
                buildContext.TryTakeException(argument1.Exception, "Sys.Atn2");
                buildContext.TryTakeException(argument2.Exception, "Sys.Atn2");
                return sql;
            }));
        }