diff --git a/Btms.Analytics/MovementsAggregationService.cs b/Btms.Analytics/MovementsAggregationService.cs index ce31078..4009d96 100644 --- a/Btms.Analytics/MovementsAggregationService.cs +++ b/Btms.Analytics/MovementsAggregationService.cs @@ -98,16 +98,10 @@ public Task ByUniqueDocumentReferenceCount(DateTime from, .Distinct() .Count() }) - .GroupBy(g => g.Key.Linked); - + .Select(g => new { g.Key.Linked, g.Key.DocumentReferenceCount, MovementCount = g.Count() }); + var mongoResult = mongoQuery .Execute(logger) - .SelectMany(g => g.Select(l => new - { - Linked = g.Key, - DocumentReferenceCount = l.Key.DocumentReferenceCount, - MovementCount = l.Count() - })) .ToList(); var dictionary = mongoResult