Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }