public SelectClauseHandler(SelectClause clause) { _references = clause.Columns.ToList(); _resolvers = _references.Select(ValueResolver.Create).ToList(); if (_resolvers.OfType<AggregateValueResolver>().Any()) { _groupingHandler = new GroupingHandler( _references.Where(ReferenceIsNotAggregateFunction).Select(r => r.GetAliasOrName()).ToArray()); } }
public SelectClauseHandler(SelectClause clause) { _references = clause.Columns.ToList(); if (!(_references.Count == 1 && _references[0] is SpecialReference)) { _resolvers = _references.Select(ValueResolver.Create).ToList(); if (_resolvers.OfType <AggregateValueResolver>().Any()) { _groupingHandler = new GroupingHandler( _references.Where(ReferenceIsNotAggregateFunction).Select(r => r.GetAliasOrName()).ToArray()); } } }
public void GroupingOnSingleKeyWorks() { var source = new List<IDictionary<string, object>> { new Dictionary<string, object> {{"Id", 1}, {"Size", 1}}, new Dictionary<string, object> {{"Id", 1}, {"Size", 2}}, new Dictionary<string, object> {{"Id", 1}, {"Size", 3}}, new Dictionary<string, object> {{"Id", 2}, {"Size", 4}}, new Dictionary<string, object> {{"Id", 2}, {"Size", 5}}, new Dictionary<string, object> {{"Id", 2}, {"Size", 6}}, }; var target = new GroupingHandler("Id"); var actual = target.Group(source).ToList(); Assert.AreEqual(2, actual.Count); }