예제 #1
0
        private IParamBuilder GetQueryParamBuilder(TkDbContext context, IFieldInfo fieldName,
                                                   string fieldValue)
        {
            int len = Math.Min(fieldValue.Length, fTreeDef.TotalCount);

            if (len == fTreeDef.TotalCount)
            {
                return(SqlParamBuilder.CreateEqualSql(context, fieldName, fieldValue));
            }
            if (len == 0)
            {
                return(SqlParamBuilder.CreateSingleSql(context, fieldName,
                                                       "LIKE", fLevelProvider.GetSqlLikeValue(fTreeDef, 0, fieldValue)));
            }
            else
            {
                int    level       = fTreeDef.GetLevel(fieldValue);
                string likeValue   = fLevelProvider.GetSqlLikeValue(fTreeDef, level + 1, fieldValue);
                string exceptValue = fLevelProvider.GetSqlExceptValue(fTreeDef, level + 1, fieldValue);
                return(CodeLikeParamBuilder.CreateLikeSql(context, fieldName, likeValue, exceptValue));
            }
        }
예제 #2
0
        private IEnumerable <ITreeNode> SelectChildNode(string parentId, int level)
        {
            string        value     = fProvider.GetSqlLikeValue(fDefinition, level, parentId);
            IFieldInfo    fieldInfo = fSelector.GetFieldInfo(fDefinition.IdField);
            IParamBuilder builder   = SqlParamBuilder.CreateSingleSql(fSelector.Context,
                                                                      fieldInfo, "LIKE", value);

            if (!string.IsNullOrEmpty(parentId))
            {
                builder = SqlParamBuilder.CreateParamBuilder(builder,
                                                             SqlParamBuilder.CreateSingleSql(fSelector.Context, fieldInfo,
                                                                                             "<>", fDefinition.IdField + 1, parentId));
            }
            return(TreeUtil.SelectData(fSelector, this, () => fSelector.Select(builder), null).ToArray());
        }
예제 #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);
        }