Beispiel #1
0
        //public static Expression GetFilterLambdaWithParameters(string query, Type itemType)
        //{
        //    EvoQLBuilder builder = new EvoQLBuilder(query);

        //    ParameterExpression parameterExpression;
        //    EvoQLExpression parse;

        //    return builder.GetFilterLambdaWithParameters(out parse, out parameterExpression);
        //}

        public static Expression GetWhereExpression(string query, Type itemType)
        {
            EvoQLBuilder builder = new EvoQLBuilder(query);

            ParameterExpression parameterExpression;
            EvoQLExpression     parse;

            var filterexpr = builder.GetFilterExpression(out parse, out parameterExpression);

            var queryexpr = ReduceExpressionGeneration.GetMapreduceExpression(filterexpr, null, null, itemType);

            return(queryexpr);
        }
Beispiel #2
0
        public static Expression GetReduceExpression(string query, Type itemType)
        {
            EvoQLBuilder builder = new EvoQLBuilder(query);

            ParameterExpression parameterExpression;
            EvoQLExpression     parse;

            var filterexpr = builder.GetFilterExpression(out parse, out parameterExpression);

            var get = parse.Tree as GetExpression;

            //var interval = get.Interval == null ? null : new IntervalTypes?( TryParseEnum(get.Interval, IntervalTypes.None) );
            //var select = TryParseEnum(get.Select, SelectTypes.Count);

            var groupBySortDirection   = get.GroupByDescending.HasValue ? (get.GroupByDescending == true ? new OrderTypes?(OrderTypes.Descending): new OrderTypes?(OrderTypes.Ascending)) : null;
            var groupOverSortDirection = get.GroupOverDescending.HasValue ? (get.GroupOverDescending == true ? new OrderTypes?(OrderTypes.Descending) : new OrderTypes?(OrderTypes.Ascending)) : null;

            var dimensions = new ReduceDimension[]
            {
                new ReduceDimension {
                    GroupBy = get.GroupBy, OrderBy = new SelectDescriptor {
                        SourcePath = get.GroupByOrderBy
                    }, Order = groupBySortDirection, Take = get.GroupByTake, Interval = get.GroupByInterval
                },
                new ReduceDimension {
                    GroupBy = get.GroupOver, OrderBy = new SelectDescriptor {
                        SourcePath = get.GroupOverOrderBy
                    }, Order = groupOverSortDirection, Take = get.GroupOverTake, Interval = get.GroupOverInterval
                }
            };

            //foreach (var d in dimensions) if (d.GroupBy == GroupByTypes.Date) d.Interval = interval;

            var aggregate  = get.Select == "Count" ? "Count" : "Sum";
            var sourcePath = get.Select == "Count" ? null : get.Select;

            var reduceexpr = ReduceExpressionGeneration.GetMapreduceExpression(filterexpr, new SelectDescriptor {
                TargetPath = get.Select, SourcePath = sourcePath, Aggregate = aggregate
            }, dimensions, itemType);

            return(reduceexpr);
        }