public override IAggregateFluent <TNewResult> Unwind <TNewResult>(FieldDefinition <TResult> field, AggregateUnwindOptions <TNewResult> options) { return(WithPipeline(_pipeline.Unwind(field, options))); }
public override IAggregateFluent <TNewResult> Unwind <TNewResult>(FieldDefinition <TResult> field, AggregateUnwindOptions <TNewResult> options) { options = options ?? new AggregateUnwindOptions <TNewResult>(); const string operatorName = "$unwind"; var stage = new DelegatedPipelineStageDefinition <TResult, TNewResult>( operatorName, (s, sr) => { var newResultSerializer = options.ResultSerializer ?? (s as IBsonSerializer <TNewResult>) ?? sr.GetSerializer <TNewResult>(); var fieldName = "$" + field.Render(s, sr).FieldName; string includeArrayIndexFieldName = null; if (options.IncludeArrayIndex != null) { includeArrayIndexFieldName = options.IncludeArrayIndex.Render(newResultSerializer, sr).FieldName; } BsonValue value = fieldName; if (options.PreserveNullAndEmptyArrays.HasValue || includeArrayIndexFieldName != null) { value = new BsonDocument { { "path", fieldName }, { "preserveNullAndEmptyArrays", options.PreserveNullAndEmptyArrays, options.PreserveNullAndEmptyArrays.HasValue }, { "includeArrayIndex", includeArrayIndexFieldName, includeArrayIndexFieldName != null } }; } return(new RenderedPipelineStageDefinition <TNewResult>( operatorName, new BsonDocument(operatorName, value), newResultSerializer)); }); return(AppendStage <TNewResult>(stage)); }
/// <summary> /// Appends an unwind stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TNewResult">The type of the new result.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="field">The field to unwind.</param> /// <param name="options">The options.</param> /// <returns> /// The fluent aggregate interface. /// </returns> public static IAggregateFluent <TNewResult> Unwind <TResult, TNewResult>(this IAggregateFluent <TResult> aggregate, Expression <Func <TResult, object> > field, AggregateUnwindOptions <TNewResult> options = null) { Ensure.IsNotNull(aggregate, nameof(aggregate)); return(aggregate.AppendStage(PipelineStageDefinitionBuilder.Unwind(field, options))); }
/// <inheritdoc /> public virtual IAggregateFluent <TNewResult> Unwind <TNewResult>(FieldDefinition <TResult> field, AggregateUnwindOptions <TNewResult> options) { throw new NotImplementedException(); }
/// <summary> /// Appends an unwind stage to the pipeline. /// </summary> /// <typeparam name="TResult">The type of the result.</typeparam> /// <typeparam name="TNewResult">The type of the new result.</typeparam> /// <param name="aggregate">The aggregate.</param> /// <param name="field">The field to unwind.</param> /// <param name="options">The options.</param> /// <returns> /// The fluent aggregate interface. /// </returns> public static IAggregateFluent <TNewResult> Unwind <TResult, TNewResult>(this IAggregateFluent <TResult> aggregate, Expression <Func <TResult, object> > field, AggregateUnwindOptions <TNewResult> options = null) { Ensure.IsNotNull(aggregate, nameof(aggregate)); Ensure.IsNotNull(field, nameof(field)); return(aggregate.Unwind( new ExpressionFieldDefinition <TResult>(field), options)); }