public AggregationFilterModel <TParameters> FilterModelFor(Expression <Func <TParameters, string> > expression) { var filterName = GetFilterNameFrom(expression); if (Aggregations.ContainsKey(filterName) && Aggregations[filterName] is AggregationFilterModel <TParameters> p) { return(p); } throw new ArgumentOutOfRangeException(nameof(filterName), filterName, "Unable to find filter with the given name"); }
/// <summary> /// Returns the matching Aggregation of type Nested /// </summary> /// <param name="fieldExpression">The same expression used in the query.</param> /// <param name="limit">How many levels to check (default: 100)</param> /// <returns>Aggregation</returns> public Aggregation NestedAggregation(Expression <Func <T, object> > fieldExpression, bool filtered = false, int limit = 100) { var exists = false; var c = 0; var aggName = $"nested_{ExpressionHelper.GetPropertyName(fieldExpression)}_{c}"; while (!exists && c < limit) { if (Aggregations.ContainsKey(aggName)) { exists = true; continue; } c++; aggName = $"nested_{ExpressionHelper.GetPropertyName(fieldExpression)}_{c}"; } return(Aggregations[aggName]); }
/// <summary> /// 集団が存在するかどうか /// </summary> /// <param name="aggregationName">集団名</param> /// <returns>存在するかどうか</returns> public static bool HasAggregation(string aggregationName) => string.IsNullOrEmpty(aggregationName) == true ? false : Aggregations.ContainsKey(aggregationName);