Beispiel #1
0
        /// <summary>
        /// プレースホルダに値を適用する
        /// </summary>
        /// <param name="placeHolders"></param>
        /// <remarks></remarks>
        public void Place(Dictionary <string, string> placeHolders)
        {
            if (_placedHolders == null)
            {
                _placedHolders = new Dictionary <string, INode>();
            }

            // プレースホルダノード単体の場合はReplacePlaceHoldersで置き換えられない
            if (this.IsPlaceHolderOnly)
            {
                var placeHolderName = ((PlaceHolderPredicate)_predicate).LabelName;
                if (placeHolders.ContainsKey(placeHolderName))
                {
                    try {
                        _predicate = MiniSqlParserAST.CreatePredicate(placeHolders[placeHolderName]);
                        // 適用したプレースホルダを記録する
                        if (!_placedHolders.ContainsKey(placeHolderName))
                        {
                            _placedHolders.Add(placeHolderName, _predicate);
                        }
                        return;
                    } catch (SqlSyntaxErrorsException ex) {;
                                                           throw new CannotBuildASTException("Type of placeholder value is mismatched", ex); }
                }
            }

            // プレースホルダに値を適用する
            var visitor = new ReplacePlaceHolders(placeHolders);

            _predicate.Accept(visitor);

            // 適用したプレースホルダを記録する
            foreach (var placedHolder in visitor.PlacedHolders)
            {
                if (!_placedHolders.ContainsKey(placedHolder.Key))
                {
                    _placedHolders.Add(placedHolder.Key, placedHolder.Value);
                }
            }
        }
Beispiel #2
0
        public void SetPlaceHolder(Dictionary <string, string> placeHolders)
        {
            var visitor = new ReplacePlaceHolders(placeHolders);

            this.GetStmt().Accept(visitor);
        }