Example #1
0
 /// <summary>
 /// Specifies the additional negative search condition for the rows returned by the query based on the comparison between the two scalar arguments.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="argument1">Is the first argument in the equality expression.</param>
 /// <param name="argument2">Is the second argument in the equality expression.</param>
 public static WhereOrChainer OrNot(this IWhereOr prev, ScalarArgument argument1, ValueScalarArgument argument2)
 {
     return(new WhereOrChainer((Chainer)prev, argument1, argument2, false));
 }
 /// <summary>
 /// <para>Provides a predicate of a subject. A subject with a predicate returns equal or less rows than a subject without a predicate.</para>
 /// <para>All predicate methods are logically identical.</para>
 /// </summary>
 /// <typeparam name="T">The type of the subject node.</typeparam>
 /// <param name="node">A subject node.</param>
 /// <param name="quantifier">A quantifier of a predicate.</param>
 /// <param name="argument1">The first argument in the equality expression.</param>
 /// <param name="argument2">The second argument in the equality expression.</param>
 public static T BelongingTo <T>(this T node, Quantifier quantifier, ScalarArgument argument1, ValueScalarArgument argument2)
     where T : ISemantic
 {
     return(AddPredicate(node, argument1, argument2, true, quantifier));
 }
Example #3
0
 /// <summary>
 /// Specifies the additional negative search condition for the rows returned by the query based on the comparison between the two scalar arguments.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="argument1">Is the first scalar argument.</param>
 /// <param name="argument2">Is the second scalar argument.</param>
 public static OnOrChainer OrNot(this IOnOr prev, ScalarArgument argument1, ScalarArgument argument2)
 {
     return(new OnOrChainer((Chainer)prev, argument1, argument2, false));
 }
 /// <summary>
 /// Combines two Boolean expressions and returns TRUE when both expressions are TRUE. When more than one logical operator, the order of evaluation can be controled using parentheses.
 /// </summary>
 /// <param name="firstExpression">Is any valid expression that returns a Boolean value.</param>
 /// <param name="argument1">Is the first argument in the equality expression.</param>
 /// <param name="argument2">Is the second argument in the equality expression.</param>
 public static Expression And(this Expression firstExpression, ScalarArgument argument1, ValueScalarArgument argument2)
 {
     return(new Expression(Operator.And, firstExpression, Expression.EqualitySimplifier(argument1, argument2, true)));
 }
 /// <summary>
 /// Returns the remainder of one number divided by another.
 /// </summary>
 /// <param name="dividend">Is the numeric expression to divide.</param>
 /// <param name="divisor">Is the numeric expression by which to divide the dividend.</param>
 public static Expression Modulo(this string dividend, ScalarArgument divisor)
 {
     return(new Expression(Operator.Modulo, dividend, divisor));
 }
Example #6
0
        /// <summary>
        /// <para>STUFF built-in function.</para>
        /// <para>The STUFF function inserts a string into another string. It deletes a specified length of characters in the first string at the start position and then inserts the second string into the first string at the start position.</para>
        /// </summary>
        /// <param name="argument">Is an expression of character data. textual can be a constant, variable, or column of either character or binary data.</param>
        /// <param name="start">Is an integer value that specifies the location to start deletion and insertion.</param>
        /// <param name="length">Is an integer that specifies the number of characters to delete.</param>
        /// <param name="replaceWith">Is an expression of character data. replaceWith can be a constant, variable, or column of either character or binary data.</param>
        public static SysFn Stuff(ScalarArgument argument, ScalarArgument start, ScalarArgument length, ScalarArgument replaceWith)
        {
            argument = argument ?? Designer.Null;
            start    = start ?? Designer.Null;
            length   = length ?? Designer.Null;
            if (replaceWith == null)
            {
                replaceWith = Designer.Null;
            }

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "STUFF({0},{1},{2},{3})",
                    argument.Build(buildContext, buildArgs),
                    start.Build(buildContext, buildArgs),
                    length.Build(buildContext, buildArgs),
                    replaceWith.Build(buildContext, buildArgs));
                buildContext.TryTakeException(argument.Exception, "Sys.Stuff");
                buildContext.TryTakeException(start.Exception, "Sys.Stuff");
                buildContext.TryTakeException(length.Exception, "Sys.Stuff");
                buildContext.TryTakeException(replaceWith.Exception, "Sys.Stuff");
                return sql;
            }));
        }
Example #7
0
 /// <summary>
 /// <para>Provides a predicate of a subject. A subject with a predicate returns equal or less rows than a subject without a predicate.</para>
 /// <para>All predicate methods are logically identical.</para>
 /// </summary>
 /// <typeparam name="T">The type of the subject node.</typeparam>
 /// <param name="node">A subject node.</param>
 /// <param name="quantifier">A quantifier of a predicate.</param>
 /// <param name="argument1">The first argument in the equality expression.</param>
 /// <param name="argument2">The second argument in the equality expression.</param>
 public static T WhichHas <T>(this T node, Quantifier quantifier, ScalarArgument argument1, ValueScalarArgument argument2)
     where T : ISemantic
 {
     return(RelatedTo(node, quantifier, argument1, argument2));
 }
 /// <summary>
 /// Multiplies two numbers.
 /// </summary>
 /// <param name="firstNumeric">The first numeric expression to multiply.</param>
 /// <param name="secondNumeric">The second numeric expression to multiply.</param>
 public static Expression MultiplyBy(this string firstNumeric, ScalarArgument secondNumeric)
 {
     return(new Expression(Operator.MultiplyBy, firstNumeric, secondNumeric));
 }
 /// <summary>
 /// Multiplies two numbers.
 /// </summary>
 /// <param name="firstNumeric">The first numeric expression to multiply.</param>
 /// <param name="secondNumeric">The second numeric expression to multiply.</param>
 public static Expression MultiplyBy(this IScalar firstNumeric, ScalarArgument secondNumeric)
 {
     return(new Expression(Operator.MultiplyBy, new ScalarArgument(firstNumeric), secondNumeric));
 }
 /// <summary>
 /// Performs a bitwise exclusive OR operation between two integer values.
 /// </summary>
 /// <param name="firstNumeric">Is the first number for the bitwise operation.</param>
 /// <param name="secondNumeric">Is the second number for the bitwise operation.</param>
 public static Expression ExclusiveOrBitwise(this IScalar firstNumeric, ScalarArgument secondNumeric)
 {
     return(new Expression(Operator.ExclusiveOrBitwise, new ScalarArgument(firstNumeric), secondNumeric));
 }
 /// <summary>
 /// Adds two expressions.
 /// </summary>
 /// <param name="firstExpression">The first expression to add.</param>
 /// <param name="secondExpression">The second expression to add.</param>
 public static Expression Plus(this IScalar firstExpression, ScalarArgument secondExpression)
 {
     return(new Expression(Operator.Plus, new ScalarArgument(firstExpression), secondExpression));
 }
 /// <summary>
 /// Adds two expressions.
 /// </summary>
 /// <param name="firstExpression">The first expression to add.</param>
 /// <param name="secondExpression">The second expression to add.</param>
 public static Expression Plus(this string firstExpression, ScalarArgument secondExpression)
 {
     return(new Expression(Operator.Plus, firstExpression, secondExpression));
 }
 /// <summary>
 /// Performs a bitwise logical OR operation between two integer values.
 /// </summary>
 /// <param name="firstNumeric">Is the first number for the bitwise operation.</param>
 /// <param name="secondNumeric">Is the second number for the bitwise operation.</param>
 public static Expression OrBitwise(this string firstNumeric, ScalarArgument secondNumeric)
 {
     return(new Expression(Operator.OrBitwise, firstNumeric, secondNumeric));
 }
 /// <summary>
 /// Returns the remainder of one number divided by another.
 /// </summary>
 /// <param name="dividend">Is the numeric expression to divide.</param>
 /// <param name="divisor">Is the numeric expression by which to divide the dividend.</param>
 public static Expression Modulo(this IScalar dividend, ScalarArgument divisor)
 {
     return(new Expression(Operator.Modulo, new ScalarArgument(dividend), divisor));
 }
Example #15
0
        /// <summary>
        /// <para>DATEDIFF built-in function.</para>
        /// <para>Returns an integer that represents the specified datepart of the specified date.</para>
        /// </summary>
        /// <param name="datePart">Is the part of date (a date or time value) for which an integer will be returned.</param>
        /// <param name="startDate">Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable or string literal.</param>
        /// <param name="endDate">Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable or string literal.</param>
        public static SysFn Datediff(Designer.PartOfDate datePart, ScalarArgument startDate, ScalarArgument endDate)
        {
            startDate = startDate ?? Designer.Null;
            endDate   = endDate ?? Designer.Null;

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "DATEDIFF({0},{1},{2})",
                    datePart.ToUpperCase(),
                    startDate.Build(buildContext, buildArgs),
                    endDate.Build(buildContext, buildArgs));
                buildContext.TryTakeException(startDate.Exception, "Sys.Datediff");
                buildContext.TryTakeException(endDate.Exception, "Sys.Datediff");
                return sql;
            }));
        }
 /// <summary>
 /// Divides two numbers.
 /// </summary>
 /// <param name="dividend">Is the numeric expression to divide.</param>
 /// <param name="divisor">Is the numeric expression by which to divide the dividend.</param>
 public static Expression DivideBy(this string dividend, ScalarArgument divisor)
 {
     return(new Expression(Operator.DivideBy, dividend, divisor));
 }
Example #17
0
        /// <summary>
        /// <para>DATEADD built-in function.</para>
        /// <para>Returns a specified date with the specified number interval (signed integer) added to a specified datepart of that date.</para>
        /// </summary>
        /// <param name="datePart">Is the part of date to which an integer number is added. </param>
        /// <param name="number">Is an expression that can be resolved to an int that is added to a datepart of date. User-defined variables are valid.</param>
        /// <param name="date">Is an expression that can be resolved to a time, date, smalldatetime, datetime, datetime2, or datetimeoffset value. date can be an expression, column expression, user-defined variable, or string literal. If the expression is a string literal, it must resolve to a datetime.</param>
        public static SysFn Dateadd(Designer.PartOfDate datePart, ScalarArgument number, ScalarArgument date)
        {
            number = number ?? Designer.Null;
            date   = date ?? Designer.Null;

            return(new SysFn((buildContext, buildArgs) =>
            {
                var sql = String.Format(
                    "DATEADD({0},{1},{2})",
                    datePart.ToUpperCase(),
                    number.Build(buildContext, buildArgs),
                    date.Build(buildContext, buildArgs));
                buildContext.TryTakeException(number.Exception, "Sys.Dateadd");
                buildContext.TryTakeException(date.Exception, "Sys.Dateadd");
                return sql;
            }));
        }
Example #18
0
 /// <summary>
 /// Specifies a search condition for a group or an aggregate.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="argument1">Is the first argument.</param>
 /// <param name="argument2">Is the second argument.</param>
 /// <param name="equality">Specifies the type of the relation between the two arguments. true indicates the equality operator, false indicates the inequality operator.</param>
 public static HavingChainer Having(this IHaving prev, ScalarArgument argument1, ScalarArgument argument2, bool equality = true)
 {
     return(new HavingChainer((Chainer)prev, argument1, argument2, equality));
 }
Example #19
0
        /// <summary>
        /// <para>CHARINDEX built-in function.</para>
        /// <para>Searches an expression for another expression and returns its starting position if found.</para>
        /// </summary>
        /// <param name="toFind">Is a character expression that contains the sequence to be found. toFind is limited to 8000 characters.</param>
        /// <param name="toSearch">Is a character expression to be searched.</param>
        /// <param name="startLocation">Is an integer or bigint expression at which the search starts. If startLocation is not specified, is a negative number, or is 0, the search starts at the beginning of toSearch.</param>
        public static SysFn Charindex(ScalarArgument toFind, ScalarArgument toSearch, ScalarArgument startLocation = null)
        {
            toFind   = toFind ?? Designer.Null;
            toSearch = toSearch ?? Designer.Null;

            if (startLocation == null)
            {
                return(new SysFn((buildContext, buildArgs) =>
                {
                    var sql = String.Format(
                        "CHARINDEX({0},{1})",
                        toFind.Build(buildContext, buildArgs),
                        toSearch.Build(buildContext, buildArgs));
                    buildContext.TryTakeException(toFind.Exception, "Sys.CharIndex");
                    buildContext.TryTakeException(toSearch.Exception, "Sys.CharIndex");
                    return sql;
                }));
            }
            else
            {
                return(new SysFn((buildContext, buildArgs) =>
                {
                    var sql = String.Format(
                        "CHARINDEX({0},{1},{2})",
                        toFind.Build(buildContext, buildArgs),
                        toSearch.Build(buildContext, buildArgs),
                        startLocation.Build(buildContext, buildArgs));
                    buildContext.TryTakeException(toFind.Exception, "Sys.CharIndex");
                    buildContext.TryTakeException(toSearch.Exception, "Sys.CharIndex");
                    buildContext.TryTakeException(startLocation.Exception, "Sys.CharIndex");
                    return sql;
                }));
            }
        }
 internal static Expression NotEqualTo(this IScalar leftExpression, ScalarArgument rightExpression)
 {
     return(new Expression(Operator.NotEqual, new ScalarArgument(leftExpression), rightExpression));
 }
Example #21
0
 /// <summary>
 /// Sets a condition for the repeated execution of a SQL statement or statement block.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="argument1">Is the first argument in the equality expression.</param>
 /// <param name="argument2">Is the second argument in the equality expression.</param>
 /// <param name="equality">Specifies the type of the relation between the two arguments. true indicates the equality operator, false indicates the inequality operator.</param>
 public static WhileChainer While(this IAny prev, ScalarArgument argument1, ValueScalarArgument argument2, bool equality = true)
 {
     return(new WhileChainer((Chainer)prev, argument1, argument2, equality));
 }
Example #22
0
 /// <summary>
 /// Specifies the search condition for the rows returned by the query based on the comparison between the two scalar arguments.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="argument1">Is the first argument in the equality expression.</param>
 /// <param name="argument2">Is the second argument in the equality expression.</param>
 public static WhereChainer Where(this IWhere prev, ScalarArgument argument1, ValueScalarArgument argument2)
 {
     return(new WhereChainer((Chainer)prev, argument1, argument2, true));
 }
 /// <summary>
 /// Combines two Boolean expressions and returns TRUE when at least one expression, where the second is negated, is TRUE. When more than one logical operator, the order of evaluation can be controled using parentheses.
 /// </summary>
 /// <param name="firstExpression">Is any valid expression that returns a Boolean value.</param>
 /// <param name="argument1">Is the first argument in the equality expression.</param>
 /// <param name="argument2">Is the second argument in the equality expression.</param>
 public static Expression OrNot(this Expression firstExpression, ScalarArgument argument1, ValueScalarArgument argument2)
 {
     return(new Expression(Operator.OrNot, firstExpression, Expression.EqualitySimplifier(argument1, argument2, false)));
 }
 /// <summary>
 /// Divides two numbers.
 /// </summary>
 /// <param name="dividend">Is the numeric expression to divide.</param>
 /// <param name="divisor">Is the numeric expression by which to divide the dividend.</param>
 public static Expression DivideBy(this IScalar dividend, ScalarArgument divisor)
 {
     return(new Expression(Operator.DivideBy, new ScalarArgument(dividend), divisor));
 }