Exemple #1
0
        /// <summary>
        /// Checks if aggregation with given name is available on the result and throws if not
        /// </summary>
        public static void CheckForAggregationInResult(this AggregateDictionary aggs, string aggName)
        {
            if (aggs == null || aggs.Count == 0)
            {
                throw new InvalidOperationException("No aggregations available on the result");
            }

            if (!aggs.ContainsKey(aggName))
            {
                var availableAggregations = aggs.Select(x => x.Key).Aggregate((agg, x) => agg + "m" + x);
                throw new InvalidOperationException($"Aggregation {aggName} not in the result. Available aggregations: {availableAggregations}");
            }
        }