Example #1
0
        public DynamicQueryModel Converter()
        {
            var result = new DynamicQueryModel
            {
                IsPager = _queryModel.Pager,
                Skip    = _queryModel.Skip < 0 ? 0 : _queryModel.Skip,
                Take    = _queryModel.Take < 0 ? 10 : _queryModel.Take
            };
            var w = ConverterWhere();

            result.Where      = w.Builder.ToString();
            result.WhereValue = w.Values.ToArray();
            result.IsPager    = _queryModel.Pager;
            result.Order      = ConverterHelper.ConverterOrderBy(_queryModel.Order);
            result.Select     = ConverterSelect();
            return(result);
        }
        public void Converter(DynamicQueryParam queryParam, Type propertyType, DynamicQueryKeyValueCollection collection)
        {
            if (!propertyType.IsConstructedGenericType)
            {
                throw new Exception("只有泛型类型能够使用此方法");
            }
            var type = propertyType.GetGenericArguments().FirstOrDefault();

            if (type == null)
            {
                throw new Exception("只有泛型类型能够使用此方法");
            }
            var group = JsonConvert.DeserializeObject <DynamicQueryParamGroup>((queryParam.Value ?? "").ToString());

            if ((group == null) || (group.ChildGroups == null))
            {
                return;
            }
            ConverterHelper.CheckQueryParamGroup(group);
            collection.Builder.Append($"{queryParam.Field}.Any(");
            ConverterHelper.ConverterQueryParamGroup(type, group, collection);
            collection.Builder.Append($")");
        }
Example #3
0
 private string ConverterSelect()
 {
     return(ConverterHelper.ConverterSelect(_queryModel.Select));
 }