Beispiel #1
0
 /// <inheritdoc />
 public virtual IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TValue>(
     AggregateExpressionDefinition <TResult, TValue> groupBy,
     int buckets,
     AggregateBucketAutoOptions options = null)
 {
     throw new NotImplementedException();
 }
 public override IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TValue>(
     AggregateExpressionDefinition <TResult, TValue> groupBy,
     int buckets,
     AggregateBucketAutoOptions options = null)
 {
     return(WithPipeline(_pipeline.BucketAuto(groupBy, buckets, options)));
 }
Beispiel #3
0
        public override IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TValue>(
            AggregateExpressionDefinition <TResult, TValue> groupBy,
            int buckets,
            AggregateBucketAutoOptions options = null)
        {
            Ensure.IsNotNull(groupBy, nameof(groupBy));
            Ensure.IsGreaterThanZero(buckets, nameof(buckets));

            const string operatorName = "$bucketAuto";
            var          stage        = new DelegatedPipelineStageDefinition <TResult, AggregateBucketAutoResult <TValue> >(
                operatorName,
                (s, sr) =>
            {
                var renderedGroupBy = groupBy.Render(s, sr);
                var document        = new BsonDocument
                {
                    { operatorName, new BsonDocument
                      {
                          { "groupBy", renderedGroupBy },
                          { "buckets", buckets },
                          { "granularity", () => options.Granularity.Value.Value, options != null && options.Granularity.HasValue }
                      } }
                };
                return(new RenderedPipelineStageDefinition <AggregateBucketAutoResult <TValue> >(
                           operatorName,
                           document,
                           sr.GetSerializer <AggregateBucketAutoResult <TValue> >()));
            });

            return(AppendStage(stage));
        }
 public override IAggregateFluent <TNewResult> BucketAuto <TValue, TNewResult>(
     AggregateExpressionDefinition <TResult, TValue> groupBy,
     int buckets,
     ProjectionDefinition <TResult, TNewResult> output,
     AggregateBucketAutoOptions options = null)
 {
     return(WithPipeline(_pipeline.BucketAuto(groupBy, buckets, output, options)));
 }
Beispiel #5
0
 /// <inheritdoc />
 public virtual IAggregateFluent <TNewResult> BucketAuto <TValue, TNewResult>(
     AggregateExpressionDefinition <TResult, TValue> groupBy,
     int buckets,
     ProjectionDefinition <TResult, TNewResult> output,
     AggregateBucketAutoOptions options = null)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Appends a $bucketAuto 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="buckets">The number of buckets.</param>
 /// <param name="options">The options (optional).</param>
 /// <returns>The fluent aggregate interface.</returns>
 public static IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TResult, TValue>(
     this IAggregateFluent <TResult> aggregate,
     Expression <Func <TResult, TValue> > groupBy,
     int buckets,
     AggregateBucketAutoOptions options = null)
 {
     Ensure.IsNotNull(aggregate, nameof(aggregate));
     return(aggregate.AppendStage(PipelineStageDefinitionBuilder.BucketAuto(groupBy, buckets, options)));
 }
Beispiel #7
0
        /// <summary>
        /// Appends a $bucketAuto 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="buckets">The number of buckets.</param>
        /// <param name="options">The options (optional).</param>
        /// <returns>The fluent aggregate interface.</returns>
        public static IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TResult, TValue>(
            this IAggregateFluent <TResult> aggregate,
            Expression <Func <TResult, TValue> > groupBy,
            int buckets,
            AggregateBucketAutoOptions options = null)
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));
            Ensure.IsNotNull(groupBy, nameof(groupBy));

            var groupByDefinition = new ExpressionAggregateExpressionDefinition <TResult, TValue>(groupBy, aggregate.Options.TranslationOptions);

            return(aggregate.BucketAuto(groupByDefinition, buckets, options));
        }
Beispiel #8
0
        /// <summary>
        /// Appends a $bucketAuto stage to the pipeline.
        /// </summary>
        /// <typeparam name="TResult">The type of the result.</typeparam>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <typeparam name="TNewResult">The type of the new result.</typeparam>
        /// <param name="aggregate">The aggregate.</param>
        /// <param name="groupBy">The expression providing the value to group by.</param>
        /// <param name="buckets">The number of buckets.</param>
        /// <param name="output">The output projection.</param>
        /// <param name="options">The options (optional).</param>
        /// <returns>The fluent aggregate interface.</returns>
        public static IAggregateFluent <TNewResult> BucketAuto <TResult, TValue, TNewResult>(
            this IAggregateFluent <TResult> aggregate,
            Expression <Func <TResult, TValue> > groupBy,
            int buckets,
            Expression <Func <IGrouping <TValue, TResult>, TNewResult> > output,
            AggregateBucketAutoOptions options = null)
        {
            Ensure.IsNotNull(aggregate, nameof(aggregate));
            Ensure.IsNotNull(groupBy, nameof(groupBy));
            Ensure.IsNotNull(output, nameof(output));

            var groupByDefinition = new ExpressionAggregateExpressionDefinition <TResult, TValue>(groupBy, aggregate.Options.TranslationOptions);
            var outputDefinition  = new ExpressionBucketOutputProjection <TResult, TValue, TNewResult>(x => default(TValue), output, aggregate.Options.TranslationOptions);

            return(aggregate.BucketAuto(groupByDefinition, buckets, outputDefinition, options));
        }