Example #1
0
 public override void VisitAfter(BracketedPredicate predicate)
 {
     if (IsPlaceHolderPredicate(predicate.Operand))
     {
         predicate.Operand = Place((PlaceHolderPredicate)predicate.Operand);
     }
 }
Example #2
0
        /// <summary>
        /// 論理式条件を追加する
        /// </summary>
        /// <param name="sqlExp"></param>
        /// <remarks>
        /// AddAndExpVisitorは走査対象にPredicate単体を指定された場合、
        /// そのPredicateを置き換えることはできないので利用できなかった.
        /// </remarks>
        public SqlPredicate And(SqlPredicate predicate)
        {
            //predicateがNullの場合、処理を終了する
            if (predicate == null || predicate.IsEmpty)
            {
                return(this);
            }
            else if (_predicate.GetType() == typeof(NullPredicate))
            {
                return(new SqlPredicate(predicate._predicate));
            }

            Predicate leftPredicate;

            if (_predicate.GetType() == typeof(OrPredicate))
            {
                leftPredicate = new BracketedPredicate(_predicate);
            }
            else
            {
                leftPredicate = _predicate;
            }

            Predicate rightPredicate;

            if (predicate._predicate.GetType() == typeof(OrPredicate))
            {
                rightPredicate = new BracketedPredicate(predicate._predicate);
            }
            else
            {
                rightPredicate = predicate._predicate;
            }

            // PlacedHoldersをマージする
            Dictionary <string, INode> newPlacedHolders = null;

            if (_placedHolders == null)
            {
                newPlacedHolders = predicate._placedHolders;
            }
            else if (predicate._placedHolders == null)
            {
                newPlacedHolders = _placedHolders;
            }
            else
            {
                foreach (var placedHolder in predicate._placedHolders)
                {
                    if (!_placedHolders.ContainsKey(placedHolder.Key))
                    {
                        _placedHolders.Add(placedHolder.Key, placedHolder.Value);
                    }
                }
            }

            return(new SqlPredicate(new AndPredicate(leftPredicate, rightPredicate), newPlacedHolders));
        }
Example #3
0
        private Predicate AddPredicate(Predicate where)
        {
            //if(_predicate == null || _predicate.GetType() == typeof(NullPredicate)) {
            if (_predicate == null)
            {
                // 空文字、又はnullであれば構文木に何もしない
                return(where);
            }

            if (where == null)
            {
                where = _predicate;
            }
            else
            {
                Predicate leftPredicate;
                //if(AddWherePredicateVisitor.IsAndOnlyPredicate(where)) {
                //  // AND連言の場合
                //  leftPredicate = where;
                //} else {
                //  // AND連言でない場合はWhere句の式を括弧で囲んでAND節をつなげる
                //  leftPredicate = new BracketedPredicate(where);
                //}
                if (where.GetType() == typeof(OrPredicate))
                {
                    // WHERE句が、A OR Bの場合(A OR B)のように括弧で囲む
                    leftPredicate = new BracketedPredicate(where);
                }
                else
                {
                    // WHERE句が、A AND Bの場合またはAのように2項演算でない場合、括弧で囲まない
                    leftPredicate = where;
                }

                // 追加するPredicateがAND連言でない場合は括弧で囲む
                Predicate rightPredicate;
                //if(AddWherePredicateVisitor.IsAndOnlyPredicate(_predicate)) {
                //  rightPredicate = _predicate;
                //} else {
                //  rightPredicate = new BracketedPredicate(_predicate);
                //}
                if (_predicate.GetType() == typeof(OrPredicate))
                {
                    // OR演算式の場合は式全体を括弧で囲んでAND節をつなげる
                    rightPredicate = new BracketedPredicate(_predicate);
                }
                else
                {
                    rightPredicate = _predicate;
                }

                where = new AndPredicate(leftPredicate, rightPredicate);
            }
            return(where);
        }
Example #4
0
        private Predicate PlaceInCollate(PlaceHolderPredicate ph)
        {
            var predicate = this.Place(ph);

            if (predicate.GetType() == typeof(AndPredicate) ||
                predicate.GetType() == typeof(OrPredicate))
            {
                predicate = new BracketedPredicate(predicate);
            }
            return(predicate);
        }
Example #5
0
        private Predicate PlaceInAnd(PlaceHolderPredicate ph)
        {
            var predicate = this.Place(ph);

            if (predicate.GetType() == typeof(OrPredicate))
            {
                // OR演算式の場合は式全体を括弧で囲んでAND節をつなげる
                predicate = new BracketedPredicate(predicate);
            }
            return(predicate);
        }
Example #6
0
 virtual public void VisitAfter(BracketedPredicate predicate)
 {
 }
Example #7
0
 virtual public void VisitBefore(BracketedPredicate predicate)
 {
 }
 public override void VisitAfter(BracketedPredicate predicate)
 {
 }
Example #9
0
 public override void VisitAfter(BracketedPredicate predicate)
 {
     --_predicateLevel;
 }
Example #10
0
 public override void VisitBefore(BracketedPredicate predicate)
 {
     ++_predicateLevel;
 }
 public void VisitAfter(BracketedPredicate predicate)
 {
     _visitor.VisitAfter(predicate);
 }
 public void VisitBefore(BracketedPredicate predicate)
 {
     _visitor.VisitBefore(predicate);
 }