Esempio n. 1
0
 public override IParamBuilder GetCondition(IFieldInfo field, string fieldValue)
 {
     if (IsEqual)
     {
         return(SqlParamBuilder.CreateParamBuilderWithOr(
                    SqlParamBuilder.CreateEqualSql(Context, fField1, fieldValue),
                    SqlParamBuilder.CreateEqualSql(Context, fField2, fieldValue)));
     }
     else
     {
         if (WordSplit)
         {
             string[]             values = fieldValue.Split(' ');
             List <IParamBuilder> items  = new List <IParamBuilder>(values.Length);
             int index = 0;
             foreach (var value in values)
             {
                 string newValue = value.Trim();
                 if (!string.IsNullOrEmpty(newValue))
                 {
                     ++index;
                     IParamBuilder builder = GetLikeParamBuilder(newValue, index);
                     items.Add(builder);
                 }
             }
             return(ParamBuilder.CreateParamBuilder(items));
         }
         else
         {
             return(GetLikeParamBuilder(fieldValue));
         }
     }
 }
Esempio n. 2
0
        private IParamBuilder CreateItemParamBuilder(string value, bool isEqual, int index = 0)
        {
            IParamBuilder[] builders = new IParamBuilder[fFields.Length];

            for (int i = 0; i < fFields.Length; ++i)
            {
                if (isEqual)
                {
                    builders[i] = SqlParamBuilder.CreateEqualSql(Context, fFields[i], value);
                }
                else
                {
                    if (index == 0)
                    {
                        builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i], value);
                    }
                    else
                    {
                        builders[i] = LikeParamBuilder.CreateLikeSql(Context, fFields[i],
                                                                     fFields[i].FieldName + index, value);
                    }
                }
            }
            return(SqlParamBuilder.CreateParamBuilderWithOr(builders));
        }
Esempio n. 3
0
        internal static IParamBuilder GetLevelBuilder(TableSelector selector,
                                                      LevelTreeDefinition treeDef, int level, string value, ILevelProvider provider)
        {
            IParamBuilder[] builders = new IParamBuilder[level + 1];
            IFieldInfo      idField  = selector.GetFieldInfo(treeDef.IdField);

            for (int i = 0; i <= level; ++i)
            {
                string likeValue = provider.GetSqlLikeValue(treeDef, i, value);
                builders[i] = SqlParamBuilder.CreateSingleSql(selector.Context, idField, "LIKE",
                                                              treeDef.IdField + i, likeValue);
            }
            IParamBuilder builder = SqlParamBuilder.CreateParamBuilderWithOr(builders);

            return(builder);
        }
Esempio n. 4
0
        internal static IParamBuilder GetValueBuilder(TableSelector selector,
                                                      DbTreeDefinition treeDef, int topLevel, NormalDataRowTreeNode node)
        {
            string layer = node.Layer;
            int    len   = layer.Length / 3;

            if (len < topLevel)
            {
                return(null);
            }

            IParamBuilder[] builders = new IParamBuilder[len - topLevel + 1];
            for (int i = 0; i < builders.Length; i++)
            {
                int    subLength = (topLevel + i - 1) * 3;
                string likeValue = layer.Substring(0, subLength).PadRight(subLength + 3, '_');
                string paramName = treeDef.LayerField + i.ToString(ObjectUtil.SysCulture);
                builders[i] = SqlParamBuilder.CreateSingleSql(selector.Context,
                                                              selector.GetFieldInfo(treeDef.LayerField), "LIKE", paramName, likeValue);
            }
            IParamBuilder builder = SqlParamBuilder.CreateParamBuilderWithOr(builders);

            return(builder);
        }
Esempio n. 5
0
 private IParamBuilder GetLikeParamBuilder(string value, int index = 0)
 {
     return(SqlParamBuilder.CreateParamBuilderWithOr(
                LikeParamBuilder.CreateLikeSql(Context, fField1, fField1.FieldName + index, value),
                LikeParamBuilder.CreateLikeSql(Context, fField2, fField2.FieldName + index, value)));
 }