/// <summary> /// Appends a $bucket stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TValue">The type of the value.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="groupBy">The expression providing the value to group by.</param> /// <param name="boundaries">The bucket boundaries.</param> /// <param name="options">The options.</param> /// <returns>The fluent aggregate interface.</returns> public static IAggregateFluent <AggregateBucketResult <TValue> > Bucket <TResult, TValue>( this IAggregateFluent <TResult> aggregate, Expression <Func <TResult, TValue> > groupBy, IEnumerable <TValue> boundaries, AggregateBucketOptions <TValue> options = null) { Ensure.IsNotNull(aggregate, nameof(aggregate)); return(aggregate.AppendStage(PipelineStageDefinitionBuilder.Bucket(groupBy, boundaries, options))); }