Example #1
0
        protected override void doAddWhereClause(List <String> conditionList, String columnName, ConditionValue value, ConditionOption option)
        {
            if (option == null)
            {
                String msg = "The argument[option] should not be null: columnName=" + columnName + " value=" + value;
                throw new IllegalArgumentException(msg);
            }
            if (!(option is LikeSearchOption))
            {
                String msg = "The argument[option] should be LikeSearchOption: columnName=" + columnName + " value=" + value;
                throw new IllegalArgumentException(msg);
            }
            LikeSearchOption myOption = (LikeSearchOption)option;

            conditionList.add(buildBindClauseWithRearOption(columnName, value.getLikeSearchLocation(), myOption.getRearOption()));
        }
        public void SetupValueAndType(InternalValueAndType valueAndType)
        {
            Object value = valueAndType.TargetValue;
            Type   type  = valueAndType.TargetType;

            // LikeSearchOption handling here is for OutsideSql.
            LikeSearchOption likeSearchOption = null;
            String           rearOption       = null;

            for (int pos = 1; pos < _names.Length; ++pos)
            {
                if (value == null)
                {
                    break;
                }
                String currentName = _names[pos];
                if (pos == 1)  // at the First Loop
                {
                    if (HasLikeSearchOption(type, currentName))
                    {
                        likeSearchOption = GetLikeSearchOption(type, currentName, value);
                    }
                }
                if (value is System.Collections.IDictionary)
                {
                    System.Collections.IDictionary map = (System.Collections.IDictionary)value;
                    value = map[currentName];
                    if (IsLastLoop4LikeSearch(pos, likeSearchOption) && IsValidStringValue(value))  // at the Last Loop
                    {
                        value      = likeSearchOption.generateRealValue((String)value);
                        rearOption = likeSearchOption.getRearOption();
                    }
                    type = (value != null ? value.GetType() : type);
                    continue;
                }
                if (value is NgMap)
                {
                    NgMap map = (NgMap)value;
                    value = map.getAsNg(currentName);
                    if (IsLastLoop4LikeSearch(pos, likeSearchOption) && IsValidStringValue(value))  // at the Last Loop
                    {
                        value      = likeSearchOption.generateRealValue((String)value);
                        rearOption = likeSearchOption.getRearOption();
                    }
                    type = (value != null ? value.GetType() : type);
                    continue;
                }
                PropertyInfo pi = type.GetProperty(currentName);
                if (pi != null)
                {
                    value = pi.GetValue(value, null);
                    if (IsLastLoop4LikeSearch(pos, likeSearchOption) && IsValidStringValue(value))  // at the Last Loop
                    {
                        value      = likeSearchOption.generateRealValue((String)value);
                        rearOption = likeSearchOption.getRearOption();
                    }
                    type = (value != null ? value.GetType() : pi.PropertyType);
                    continue;
                }
                if (pos == 1 && typeof(MapParameterBean).IsAssignableFrom(type))
                {
                    MapParameterBean             pmb = (MapParameterBean)value;
                    IDictionary <String, Object> map = pmb.ParameterMap;
                    Object elementValue = (map != null && map.ContainsKey(currentName) ? map[currentName] : null);
                    if (elementValue != null)
                    {
                        value = elementValue;
                        type  = elementValue.GetType();
                        continue;
                    }
                }
                ThrowBindOrEmbeddedCommentNotFoundPropertyException(_expression, type, currentName, _specifiedSql, _bind);
            }
            valueAndType.TargetValue = value;
            valueAndType.TargetType  = type;
            valueAndType.RearOption  = rearOption;
        }