コード例 #1
0
ファイル: Extensions_Or.cs プロジェクト: amosvoron/querytalk
 /// <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));
 }
コード例 #2
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 BelongingTo <T>(this T node, Quantifier quantifier, ScalarArgument argument1, ValueScalarArgument argument2)
     where T : ISemantic
 {
     return(AddPredicate(node, argument1, argument2, true, quantifier));
 }
コード例 #3
0
ファイル: Extensions_Or.cs プロジェクト: amosvoron/querytalk
 /// <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));
 }
コード例 #4
0
 /// <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)));
 }
コード例 #5
0
 /// <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));
 }
コード例 #6
0
ファイル: Fn_String.cs プロジェクト: amosvoron/querytalk
        /// <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;
            }));
        }
コード例 #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));
 }
コード例 #8
0
 /// <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));
 }
コード例 #9
0
 /// <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));
 }
コード例 #10
0
 /// <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));
 }
コード例 #11
0
 /// <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));
 }
コード例 #12
0
 /// <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));
 }
コード例 #13
0
 /// <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));
 }
コード例 #14
0
 /// <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));
 }
コード例 #15
0
ファイル: Fn_Datetime.cs プロジェクト: amosvoron/querytalk
        /// <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;
            }));
        }
コード例 #16
0
 /// <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));
 }
コード例 #17
0
ファイル: Fn_Datetime.cs プロジェクト: amosvoron/querytalk
        /// <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;
            }));
        }
コード例 #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));
 }
コード例 #19
0
ファイル: Fn_String.cs プロジェクト: amosvoron/querytalk
        /// <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;
                }));
            }
        }
コード例 #20
0
 internal static Expression NotEqualTo(this IScalar leftExpression, ScalarArgument rightExpression)
 {
     return(new Expression(Operator.NotEqual, new ScalarArgument(leftExpression), rightExpression));
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #23
0
 /// <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)));
 }
コード例 #24
0
 /// <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));
 }