Esempio n. 1
0
        // a ctor for .WhereExists support
        internal ConditionChainer(Chainer prev, INonSelectView nonSelectView, bool exists,
                                  PredicateGroup predicateGroup = null)
            : this(prev, predicateGroup)
        {
            CheckNullAndThrow(Arg(() => nonSelectView, nonSelectView));

            SelectChainer select = new SelectChainer((Chainer)nonSelectView, new Column[] { Designer.Null }, false);
            var           view   = new View(select, Query);

            Query.AddArguments(view.Query.Arguments.ToArray());

            Build = (buildContext, buildArgs) =>
            {
                string keyword = exists ? Text.Exists : Text.NotExists;

                var sql = Text.GenerateSql(100)
                          .NewLine(predicateGroup.Build(PredicateGroupType.Begin, Keyword)).S()
                          .Append(prev.ExpressionGroupType.IsBegin() ? Text.LeftBracket : null)
                          .Append(keyword).S()
                          .EncloseLeft()
                          .Append(view.Build(buildContext, buildArgs))
                          .EncloseRight()
                          .Append(prev.ExpressionGroupType.IsEnd() ? Text.RightBracket : null)
                          .Append(predicateGroup.Build(PredicateGroupType.End, null))
                          .S();

                TryThrow(buildContext);

                return(sql.ToString());
            };
        }
Esempio n. 2
0
        internal static WhereChainer WhereQuantified(this IWhere prev, INonSelectView nonSelectView, bool sign, Predicate predicate)
        {
            var expression = predicate.Quantifier
                             .CreateExpression(((ISelect)nonSelectView).SelectCountBig().EndView());

            return(Where(prev, expression, sign, predicate.PredicateGroup));
        }
Esempio n. 3
0
        internal ElseIfChainer(Chainer prev, INonSelectView nonSelectView, bool sign)
            : base(prev)
        {
            chainMethod = Text.Method.ElseIfExists;
            CheckNullAndThrow(Arg(() => nonSelectView, nonSelectView));

            SelectChainer select = new SelectChainer((Chainer)nonSelectView, new Column[] { Designer.Null }, false);
            var           view   = new View(select, select.Query);

            Build = BuildViewMethod(view, sign);
        }
Esempio n. 4
0
 internal static ConditionChainer WhereExists(this ConditionChainer prev, INonSelectView nonSelectView, bool sign, Predicate predicate)
 {
     if (predicate.LogicalOperator == LogicalOperator.And)
     {
         return(new WhereAndChainer((Chainer)prev, nonSelectView, sign, predicate.PredicateGroup));
     }
     else
     {
         return(new WhereOrChainer((Chainer)prev, nonSelectView, sign, predicate.PredicateGroup));
     }
 }
Esempio n. 5
0
        internal static ConditionChainer WhereQuantified(this ConditionChainer prev, INonSelectView nonSelectView, bool sign, Predicate predicate)
        {
            var expression = predicate.Quantifier
                             .CreateExpression(((ISelect)nonSelectView).SelectCountBig().EndView());

            if (predicate.LogicalOperator == LogicalOperator.And)
            {
                return(AndWhere(prev, expression, sign, predicate.PredicateGroup));
            }
            else
            {
                return(OrWhere(prev, expression, sign, predicate.PredicateGroup));
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Specifies a view (subquery) to test for the negation of the existence of rows.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="nonSelectView">Is a subquery without the .Select method.</param>
 public static WhereAndChainer AndNotExists(this IWhereAnd prev, INonSelectView nonSelectView)
 {
     return(new WhereAndChainer((Chainer)prev, nonSelectView, false));
 }
Esempio n. 7
0
 internal static WhereChainer WhereExists(this IWhere prev, INonSelectView nonSelectView, bool sign,
                                          PredicateGroup predicateGroup = null)
 {
     return(new WhereChainer((Chainer)prev, nonSelectView, sign, predicateGroup));
 }
Esempio n. 8
0
 // .AndExists
 internal WhereAndChainer(Chainer prev, INonSelectView nonSelectView, bool exists, PredicateGroup predicateGroup = null)
     : base(prev, nonSelectView, exists, predicateGroup)
 {
     Query.Clause.Wheres.Add(this);
     chainMethod = exists ? Text.Method.AndExists : Text.Method.AndNotExists;
 }
Esempio n. 9
0
 /// <summary>
 /// Specifies a view (subquery) to test for the existence of rows.
 /// </summary>
 /// <param name="prev">A predecessor object.</param>
 /// <param name="nonSelectView">Is a subquery without the .Select method.</param>
 public static WhereOrChainer OrExists(this IWhereOr prev, INonSelectView nonSelectView)
 {
     return(new WhereOrChainer((Chainer)prev, nonSelectView, true));
 }
Esempio n. 10
0
 /// <summary>
 /// Returns TRUE if a query does not contains any rows.
 /// </summary>
 /// <param name="prev">Is a predecessor object.</param>
 /// <param name="nonSelectView">Is a subquery without the .Select method.</param>
 public static IfChainer IfNotExists(this IAny prev, INonSelectView nonSelectView)
 {
     return(new IfChainer((Chainer)prev, nonSelectView, false));
 }
Esempio n. 11
0
 /// <summary>
 /// Returns TRUE if a query contains any rows.
 /// </summary>
 /// <param name="prev">Is a predecessor object.</param>
 /// <param name="nonSelectView">Is a subquery without the .Select method.</param>
 public static ElseIfChainer ElseIfExists(this IAny prev, INonSelectView nonSelectView)
 {
     return(new ElseIfChainer((Chainer)prev, nonSelectView, true));
 }