/// <inheritdoc /> public virtual IAggregateFluent <AggregateBucketResult <TValue> > Bucket <TValue>( AggregateExpressionDefinition <TResult, TValue> groupBy, IEnumerable <TValue> boundaries, AggregateBucketOptions <TValue> options = null) { throw new NotImplementedException(); }
public override IAggregateFluent <AggregateBucketResult <TValue> > Bucket <TValue>( AggregateExpressionDefinition <TResult, TValue> groupBy, IEnumerable <TValue> boundaries, Optional <TValue> defaultBucket = default(Optional <TValue>)) { const string operatorName = "$bucket"; var stage = new DelegatedPipelineStageDefinition <TResult, AggregateBucketResult <TValue> >( operatorName, (s, sr) => { var valueSerializer = sr.GetSerializer <TValue>(); var renderedGroupBy = groupBy.Render(s, sr); var serializedBoundaries = boundaries.Select(b => valueSerializer.ToBsonValue(b)); var serializedDefaultBucket = defaultBucket.HasValue ? valueSerializer.ToBsonValue(defaultBucket.Value) : null; var document = new BsonDocument { { operatorName, new BsonDocument { { "groupBy", renderedGroupBy }, { "boundaries", new BsonArray(serializedBoundaries) }, { "default", serializedDefaultBucket, serializedDefaultBucket != null } } } }; return(new RenderedPipelineStageDefinition <AggregateBucketResult <TValue> >( operatorName, document, sr.GetSerializer <AggregateBucketResult <TValue> >())); }); return(AppendStage(stage)); }
public override IAggregateFluent <AggregateBucketResult <TValue> > Bucket <TValue>( AggregateExpressionDefinition <TResult, TValue> groupBy, IEnumerable <TValue> boundaries, AggregateBucketOptions <TValue> options = null) { return(WithPipeline(_pipeline.Bucket(groupBy, boundaries, options))); }
/// <inheritdoc /> public virtual IAggregateFluent <AggregateBucketAutoResult <TValue> > BucketAuto <TValue>( AggregateExpressionDefinition <TResult, TValue> groupBy, int buckets, AggregateBucketAutoOptions options = null) { throw new NotImplementedException(); }
/// <inheritdoc /> public virtual IAggregateFluent <BsonDocument> SetWindowFields <TPartitionBy, TWindowFields>( AggregateExpressionDefinition <TResult, TPartitionBy> partitionBy, SortDefinition <TResult> sortBy, AggregateExpressionDefinition <ISetWindowFieldsPartition <TResult>, TWindowFields> output) { 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))); }
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 <BsonDocument> SetWindowFields <TPartitionBy, TWindowFields>( AggregateExpressionDefinition <TResult, TPartitionBy> partitionBy, SortDefinition <TResult> sortBy, AggregateExpressionDefinition <ISetWindowFieldsPartition <TResult>, TWindowFields> output) { return(WithPipeline(_pipeline.SetWindowFields(partitionBy, sortBy, output))); }
/// <inheritdoc /> public virtual IAggregateFluent <AggregateBucketResult <TValue> > Bucket <TValue>( AggregateExpressionDefinition <TResult, TValue> groupBy, IEnumerable <TValue> boundaries, Optional <TValue> defaultBucket = default(Optional <TValue>)) { throw new NotImplementedException(); }
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))); }
/// <inheritdoc /> public virtual IAggregateFluent <TNewResult> BucketAuto <TValue, TNewResult>( AggregateExpressionDefinition <TResult, TValue> groupBy, int buckets, ProjectionDefinition <TResult, TNewResult> output, AggregateBucketAutoOptions options = null) { throw new NotImplementedException(); }
public override IAggregateFluent <TNewResult> GraphLookup <TFrom, TConnectFrom, TConnectTo, TStartWith, TAsElement, TAs, TNewResult>( IMongoCollection <TFrom> from, FieldDefinition <TFrom, TConnectFrom> connectFromField, FieldDefinition <TFrom, TConnectTo> connectToField, AggregateExpressionDefinition <TResult, TStartWith> startWith, FieldDefinition <TNewResult, TAs> @as, FieldDefinition <TAsElement, int> depthField, AggregateGraphLookupOptions <TFrom, TAsElement, TNewResult> options = null) { return(WithPipeline(_pipeline.GraphLookup(from, connectFromField, connectToField, startWith, @as, depthField, options))); }
/// <inheritdoc /> public virtual IAggregateFluent <TNewResult> GraphLookup <TFrom, TConnectFrom, TConnectTo, TStartWith, TAsElement, TAs, TNewResult>( IMongoCollection <TFrom> from, FieldDefinition <TFrom, TConnectFrom> connectFromField, FieldDefinition <TFrom, TConnectTo> connectToField, AggregateExpressionDefinition <TResult, TStartWith> startWith, FieldDefinition <TNewResult, TAs> @as, FieldDefinition <TAsElement, int> depthField, AggregateGraphLookupOptions <TFrom, TAsElement, TNewResult> options = null) where TAs : IEnumerable <TAsElement> { throw new NotImplementedException(); }
/// <summary> /// Appends a $graphLookup stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TFrom">The type of the from documents.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="from">The from collection.</param> /// <param name="connectFromField">The connect from field.</param> /// <param name="connectToField">The connect to field.</param> /// <param name="startWith">The start with value.</param> /// <param name="as">The as field.</param> /// <param name="depthField">The depth field.</param> /// <returns>The fluent aggregate interface.</returns> public static IAggregateFluent <BsonDocument> GraphLookup <TResult, TFrom>( this IAggregateFluent <TResult> aggregate, IMongoCollection <TFrom> from, FieldDefinition <TFrom, BsonValue> connectFromField, FieldDefinition <TFrom, BsonValue> connectToField, AggregateExpressionDefinition <TResult, BsonValue> startWith, FieldDefinition <BsonDocument, IEnumerable <BsonDocument> > @as, FieldDefinition <BsonDocument, int> depthField = null) { Ensure.IsNotNull(aggregate, nameof(aggregate)); return(aggregate.AppendStage(PipelineStageDefinitionBuilder.GraphLookup(from, connectFromField, connectToField, startWith, @as, depthField))); }
/// <summary> /// Appends a $graphLookup stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TFrom">The type of the from documents.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="from">The from collection.</param> /// <param name="connectFromField">The connect from field.</param> /// <param name="connectToField">The connect to field.</param> /// <param name="startWith">The start with value.</param> /// <param name="as">The as field.</param> /// <param name="depthField">The depth field.</param> /// <returns>The fluent aggregate interface.</returns> public static IAggregateFluent <BsonDocument> GraphLookup <TResult, TFrom>( this IAggregateFluent <TResult> aggregate, IMongoCollection <TFrom> from, FieldDefinition <TFrom, BsonValue> connectFromField, FieldDefinition <TFrom, BsonValue> connectToField, AggregateExpressionDefinition <TResult, BsonValue> startWith, FieldDefinition <BsonDocument, IEnumerable <BsonDocument> > @as, FieldDefinition <BsonDocument, int> depthField = null) { return(aggregate.GraphLookup <BsonDocument, TFrom, BsonValue, BsonValue, BsonValue, BsonDocument, IEnumerable <BsonDocument> >( from, connectFromField, connectToField, startWith, @as, depthField, null)); }
public override IAggregateFluent <TNewResult> GraphLookup <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAs, TAsEnumerable>( IMongoCollection <TFrom> from, FieldDefinition <TFrom, TConnectFrom> connectFromField, FieldDefinition <TFrom, TConnect> connectToField, AggregateExpressionDefinition <TResult, TStartWith> startWith, FieldDefinition <TNewResult, TAsEnumerable> @as, FieldDefinition <TAs, int> depthField, AggregateGraphLookupOptions <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAs, TAsEnumerable> options = null) { Ensure.IsNotNull(from, nameof(from)); Ensure.IsNotNull(connectFromField, nameof(connectFromField)); Ensure.IsNotNull(connectToField, nameof(connectToField)); Ensure.IsNotNull(startWith, nameof(startWith)); Ensure.IsNotNull(@as, nameof(@as)); Ensure.That(from.Database.DatabaseNamespace.Equals(_collection.Database.DatabaseNamespace), "From collection must be from the same database.", nameof(from)); Ensure.That(IsTConnectOrEnumerableTConnect <TConnectFrom, TConnect>(), "TConnectFrom must be either TConnect or a type that implements IEnumerable<TConnect>.", nameof(TConnectFrom)); Ensure.That(IsTConnectOrEnumerableTConnect <TStartWith, TConnect>(), "TStartWith must be either TConnect or a type that implements IEnumerable<TConnect>.", nameof(TStartWith)); const string operatorName = "$graphLookup"; var stage = new DelegatedPipelineStageDefinition <TResult, TNewResult>( operatorName, (s, sr) => { var resultSerializer = s; var newResultSerializer = options?.NewResultSerializer ?? sr.GetSerializer <TNewResult>(); var fromSerializer = options?.FromSerializer ?? sr.GetSerializer <TFrom>(); var asSerializer = options?.AsSerializer ?? sr.GetSerializer <TAs>(); var renderedConnectToField = connectToField.Render(fromSerializer, sr); var renderedStartWith = startWith.Render(resultSerializer, sr); var renderedConnectFromField = connectFromField.Render(fromSerializer, sr); var renderedAs = @as.Render(newResultSerializer, sr); var renderedDepthField = depthField?.Render(asSerializer, sr); var renderedRestrictSearchWithMatch = options?.RestrictSearchWithMatch?.Render(fromSerializer, sr); var document = new BsonDocument { { operatorName, new BsonDocument { { "from", from.CollectionNamespace.CollectionName }, { "connectFromField", renderedConnectFromField.FieldName }, { "connectToField", renderedConnectToField.FieldName }, { "startWith", renderedStartWith }, { "as", renderedAs.FieldName }, { "depthField", () => renderedDepthField.FieldName, renderedDepthField != null }, { "maxDepth", () => options.MaxDepth.Value, options != null && options.MaxDepth.HasValue }, { "restrictSearchWithMatch", renderedRestrictSearchWithMatch, renderedRestrictSearchWithMatch != null } } } }; return(new RenderedPipelineStageDefinition <TNewResult>(operatorName, document, newResultSerializer)); }); return(AppendStage <TNewResult>(stage)); }
/// <summary> /// Appends a $graphLookup stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TFrom">The type of the from documents.</typeparam> /// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam> /// <typeparam name="TConnectTo">The type of the connect to field.</typeparam> /// <typeparam name="TStartWith">The type of the start with expression (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam> /// <typeparam name="TAs">The type of the as field.</typeparam> /// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="from">The from collection.</param> /// <param name="connectFromField">The connect from field.</param> /// <param name="connectToField">The connect to field.</param> /// <param name="startWith">The start with value.</param> /// <param name="as">The as field.</param> /// <param name="options">The options.</param> /// <returns>The fluent aggregate interface.</returns> public static IAggregateFluent <TNewResult> GraphLookup <TResult, TFrom, TConnectFrom, TConnectTo, TStartWith, TAs, TNewResult>( this IAggregateFluent <TResult> aggregate, IMongoCollection <TFrom> from, FieldDefinition <TFrom, TConnectFrom> connectFromField, FieldDefinition <TFrom, TConnectTo> connectToField, AggregateExpressionDefinition <TResult, TStartWith> startWith, FieldDefinition <TNewResult, TAs> @as, AggregateGraphLookupOptions <TFrom, TFrom, TNewResult> options = null) where TAs : IEnumerable <TFrom> { Ensure.IsNotNull(aggregate, nameof(aggregate)); return(aggregate.AppendStage(PipelineStageDefinitionBuilder.GraphLookup(from, connectFromField, connectToField, startWith, @as, options))); }
public override IAggregateFluent <TNewResult> ReplaceRoot <TNewResult>(AggregateExpressionDefinition <TResult, TNewResult> newRoot) { const string operatorName = "$replaceRoot"; var stage = new DelegatedPipelineStageDefinition <TResult, TNewResult>( operatorName, (s, sr) => { var document = new BsonDocument(operatorName, new BsonDocument("newRoot", newRoot.Render(s, sr))); var outputSerializer = sr.GetSerializer <TNewResult>(); return(new RenderedPipelineStageDefinition <TNewResult>(operatorName, document, outputSerializer)); }); return(AppendStage(stage)); }
/// <summary> /// Appends a $graphLookup stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam> /// <typeparam name="TFrom">The type of the from documents.</typeparam> /// <typeparam name="TConnect">The type of the connect field.</typeparam> /// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam> /// <typeparam name="TStartWith">The type of the start with expression (must be either TConnect or a type that implements IEnumerable{TConnect}).</typeparam> /// <typeparam name="TAsEnumerable">The type of the enumerable as field.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="from">The from collection.</param> /// <param name="connectFromField">The connect from field.</param> /// <param name="connectToField">The connect to field.</param> /// <param name="startWith">The start with value.</param> /// <param name="as">The as field.</param> /// <param name="options">The options.</param> /// <returns>The fluent aggregate interface.</returns> public static IAggregateFluent <TNewResult> GraphLookup <TResult, TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TAsEnumerable>( this IAggregateFluent <TResult> aggregate, IMongoCollection <TFrom> from, FieldDefinition <TFrom, TConnectFrom> connectFromField, FieldDefinition <TFrom, TConnect> connectToField, AggregateExpressionDefinition <TResult, TStartWith> startWith, FieldDefinition <TNewResult, TAsEnumerable> @as, AggregateGraphLookupOptions <TNewResult, TFrom, TConnect, TConnectFrom, TStartWith, TFrom, TAsEnumerable> options = null) where TAsEnumerable : IEnumerable <TFrom> { Ensure.IsNotNull(aggregate, nameof(aggregate)); Ensure.IsNotNull(from, nameof(from)); Ensure.IsNotNull(connectFromField, nameof(connectFromField)); Ensure.IsNotNull(connectToField, nameof(connectToField)); Ensure.IsNotNull(startWith, nameof(startWith)); Ensure.IsNotNull(@as, nameof(@as)); var depthField = (FieldDefinition <TFrom, int>)null; return(aggregate.GraphLookup(from, connectFromField, connectToField, startWith, @as, depthField, options)); }
public override IAggregateFluent <TNewResult> Bucket <TValue, TNewResult>( AggregateExpressionDefinition <TResult, TValue> groupBy, IEnumerable <TValue> boundaries, ProjectionDefinition <TResult, TNewResult> output, AggregateBucketOptions <TValue> options = null) { Ensure.IsNotNull(groupBy, nameof(groupBy)); Ensure.IsNotNull(boundaries, nameof(boundaries)); Ensure.IsNotNull(output, nameof(output)); const string operatorName = "$bucket"; var stage = new DelegatedPipelineStageDefinition <TResult, TNewResult>( operatorName, (s, sr) => { var valueSerializer = sr.GetSerializer <TValue>(); var newResultSerializer = sr.GetSerializer <TNewResult>(); var renderedGroupBy = groupBy.Render(s, sr); var serializedBoundaries = boundaries.Select(b => valueSerializer.ToBsonValue(b)); var serializedDefaultBucket = options != null && options.DefaultBucket.HasValue ? valueSerializer.ToBsonValue(options.DefaultBucket.Value) : null; var renderedOutput = output.Render(s, sr); var document = new BsonDocument { { operatorName, new BsonDocument { { "groupBy", renderedGroupBy }, { "boundaries", new BsonArray(serializedBoundaries) }, { "default", serializedDefaultBucket, serializedDefaultBucket != null }, { "output", renderedOutput.Document } } } }; return(new RenderedPipelineStageDefinition <TNewResult>( operatorName, document, newResultSerializer)); }); return(AppendStage(stage)); }
public override IAggregateFluent <AggregateSortByCountResult <TId> > SortByCount <TId>(AggregateExpressionDefinition <TResult, TId> id) { return(WithPipeline(_pipeline.SortByCount(id))); }
public override IAggregateFluent <TNewResult> ReplaceRoot <TNewResult>(AggregateExpressionDefinition <TResult, TNewResult> newRoot) { return(WithPipeline(_pipeline.ReplaceRoot(newRoot))); }
public override IAggregateFluent <AggregateSortByCountResult <TId> > SortByCount <TId>(AggregateExpressionDefinition <TResult, TId> id) { const string operatorName = "$sortByCount"; var stage = new DelegatedPipelineStageDefinition <TResult, AggregateSortByCountResult <TId> >( operatorName, (s, sr) => { var outputSerializer = sr.GetSerializer <AggregateSortByCountResult <TId> >(); return(new RenderedPipelineStageDefinition <AggregateSortByCountResult <TId> >(operatorName, new BsonDocument(operatorName, id.Render(s, sr)), outputSerializer)); }); return(AppendStage(stage)); }
/// <inheritdoc /> public virtual IAggregateFluent <AggregateSortByCountResult <TId> > SortByCount <TId>(AggregateExpressionDefinition <TResult, TId> id) { throw new NotImplementedException(); }
/// <inheritdoc /> public virtual IAggregateFluent <TNewResult> ReplaceRoot <TNewResult>(AggregateExpressionDefinition <TResult, TNewResult> newRoot) { throw new NotImplementedException(); }