コード例 #1
0
        public DynamicQueryParamGroupBuilder CreateChildGroup(QueryRelation relation)
        {
            _paramGroup.CheckDynamicQueryParamGroup();
            var childGroup = new DynamicQueryParamGroup {
                Relation = relation
            };

            _paramGroup.ChildGroups.Add(childGroup);
            return(new DynamicQueryParamGroupBuilder(childGroup));
        }
コード例 #2
0
 public static void CheckQueryParamGroup([NotNull] DynamicQueryParamGroup group)
 {
     if (group == null)
     {
         throw new ArgumentNullException(nameof(group));
     }
     if ((group.ChildGroups != null) && group.ChildGroups.Any() && (group.Params != null) && group.Params.Any())
     {
         throw new Exception("QueryParamGroup中不能同时存在Groups和Params");
     }
 }
コード例 #3
0
 public static void ConverterQueryParamGroup(Type entityType, DynamicQueryParamGroup group,
                                             DynamicQueryKeyValueCollection collection)
 {
     CheckQueryParamGroup(group);
     if (IsParam(group))
     {
         ConverterQueryParams(entityType, group.Params, collection, group.Relation);
     }
     else
     {
         ConverterQueryParamGroups(entityType, group.ChildGroups, collection, group.Relation);
     }
 }
コード例 #4
0
 public void ConverterQueryParamGroup(DynamicQueryParamGroup group, SqlBuiderResult collection, SqlFieldMappings mappings, string
                                      parentKey)
 {
     CheckQueryParamGroup(group);
     if (IsParam(group))
     {
         ConverterQueryParams(group.Params, collection, group.Relation, mappings, parentKey);
     }
     else
     {
         ConverterQueryParamGroups(group.ChildGroups, collection, group.Relation, mappings, parentKey);
     }
 }
コード例 #5
0
 public static void ConverterDynamicQueryParamGroupFieldName(DynamicQueryParamGroup newGroup, DynamicQueryParamGroup old)
 {
     if (newGroup == null)
     {
         throw new ArgumentNullException(nameof(newGroup));
     }
     if (old == null)
     {
         throw new ArgumentNullException(nameof(old));
     }
     newGroup.Relation = old.Relation;
     if (old.Params != null && old.Params.Any())
     {
         foreach (var item in old.Params)
         {
             var param = new DynamicQueryParam();
             param.Operator = item.Operator;
             param.Field    = FieldConverter(item.Field);
             //处理特殊情况any
             if (item.Operator == QueryOperation.Any)
             {
                 var anyGroup    = JsonConvert.DeserializeObject <DynamicQueryParamGroup>(item.Value?.ToString() ?? "");
                 var newAnyGroup = new DynamicQueryParamGroup();
                 ConverterDynamicQueryParamGroupFieldName(newAnyGroup, anyGroup);
                 param.Value = JsonConvert.SerializeObject(newAnyGroup);
             }
             else
             {
                 param.Value = item.Value;
             }
             newGroup.Params.Add(param);
         }
     }
     if (old.ChildGroups != null && old.ChildGroups.Any())
     {
         foreach (var childGroup in old.ChildGroups)
         {
             var newChildGroup = new DynamicQueryParamGroup();
             ConverterDynamicQueryParamGroupFieldName(newChildGroup, childGroup);
             newGroup.ChildGroups.Add(newChildGroup);
         }
     }
 }
コード例 #6
0
        public static DynamicQuery Converter(DynamicQuery dynamicQuery)
        {
            if (dynamicQuery == null)
            {
                return(null);
            }

            var result = new DynamicQuery(dynamicQuery.Pager);

            result.Take = dynamicQuery.Take;
            result.Skip = dynamicQuery.Skip;

            result.ParamGroup = new DynamicQueryParamGroup();
            result.Order      = ConverterOrderFieldName(dynamicQuery.Order);
            if (dynamicQuery.ParamGroup != null)
            {
                var newgroup = new DynamicQueryParamGroup();
                ConverterDynamicQueryParamGroupFieldName(newgroup, dynamicQuery.ParamGroup);
                result.ParamGroup = newgroup;
            }
            result.Select = ConverterSelectFieldName(dynamicQuery.Select);
            return(result);
        }
コード例 #7
0
 public DynamicQueryParamGroupBuilder(DynamicQueryParamGroup paramGroup)
 {
     _paramGroup  = paramGroup;
     ParamBuilder = new DynamicQueryParamBuilder(_paramGroup.Params);
 }