public static Expression GetMergeExpression(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 isCount = get.Select == "Count"; var select = new SelectDescriptor { SourcePath = get.Select, Aggregate = isCount ? "Count" : "Sum", TargetPath = isCount ? "_Count" : get.Select }; var mapreduceexpr = GetReduceExpression(query, itemType); var resultType = mapreduceexpr.GetType().GetProperty("ReturnType").GetValue(mapreduceexpr, null) as Type; var resultElementType = ReduceExpressionGeneration.GetTypeOfEnumerable(resultType); //Expression mergeExpr = ReduceExpressionGeneration.GetMergeExpression(select, resultElementType); var mergeexpr = ReduceExpressionGeneration.GetMergeInvocationExpression(select, resultType); return(mergeexpr); }
public static Expression GetFilterLambda(string query, Type itemType) { EvoQLBuilder builder = new EvoQLBuilder(query); ParameterExpression parameterExpression; EvoQLExpression parse; return(builder.GetFilterLambda(out parse, out parameterExpression)); }
//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); }
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); }