diff --git a/Core.Arango.DevExtreme/ArangoTransform.cs b/Core.Arango.DevExtreme/ArangoTransform.cs index 03b95d6..a54c105 100644 --- a/Core.Arango.DevExtreme/ArangoTransform.cs +++ b/Core.Arango.DevExtreme/ArangoTransform.cs @@ -106,21 +106,53 @@ public async Task ExecuteAsync(IArangoContext arango, var query = queryBuilder.ToString(); - + if (HasGrouping) { var res = await arango.Query.ExecuteAsync(handle, query, Parameter, cancellationToken: cancellationToken); var groupData = BuildGrouping(this, res); - - return new DxLoadResult + + var dxRes = new DxLoadResult { Data = groupData, - // Experimental TotalCount = _loadOption.RequireTotalCount ? groupData.Sum(x=> x.Count ?? 0) : -1, GroupCount = _loadOption.RequireGroupCount ? groupData.Count : -1, }; + + if (_loadOption.TotalSummary?.Any() == true) + { + dxRes.Summary = Summaries.Select((x, idx) => + { + try + { + + if (x.StartsWith("SUM") || x.StartsWith("COUNT")) + return groupData.Sum(y => y.Summary[idx] ?? 0m); + if (x.StartsWith("MAX")) + return groupData.Max(y => y.Summary[idx] ?? 0m); + if (x.StartsWith("MIN")) + return groupData.Min(y => y.Summary[idx] ?? 0m); + if (x.StartsWith("AVG")) + { + return groupData.Average(y => (y.Summary[idx] ?? 0m)); + } + + + return 0m; + } + catch (Exception) + { + return (decimal?) 0m; + } + }).ToArray(); + + + } + + + return dxRes; } else {