private string ToSql(ISqlFormatter sql, IList <IColumn> select, IFilterParameters filterParams, IEnumerable <Filter> outerFilters, long skip, int take) { if (Aggregations.Count == 1) { return(Aggregations[0].ToSql(sql, select, outerFilters.Concat(Filters), filterParams, OrderBy, skip, take)); } var ordering = "a0.Value0 desc"; if (select != null && OrderBy.Count != 0) { ordering = string.Join(", ", OrderBy.Select(FindOrderingColumn)); } return(_aggregatedTemplate(new { skipAndTake = sql.SkipAndTake(skip, take), Aggregations = Aggregations.Select(x => x.ToSql(sql, select, outerFilters.Concat(Filters), filterParams)), Select = select, ordering })); }
private IList <QueryRecordJson> ConvertRecords(IEnumerable <IDictionary <string, object> > list) { var aggColumns = Aggregations.Select(x => x.Column).ToList(); var selColumns = Select.ToList(); return(list.Select(x => new QueryRecordJson { Selected = GetList(x, "Select", selColumns), Aggregated = GetList(x, "Value", aggColumns), }) .ToList()); }