@@ -946,6 +946,46 @@ public static PipelineDefinition<TInput, TOutput> ReplaceRoot<TInput, TIntermedi
946946 return pipeline . AppendStage ( PipelineStageDefinitionBuilder . ReplaceRoot ( newRoot , translationOptions ) ) ;
947947 }
948948
949+ /// <summary>
950+ /// Appends a $replaceWith stage to the pipeline.
951+ /// </summary>
952+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
953+ /// <typeparam name="TIntermediate">The type of the intermediate documents.</typeparam>
954+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
955+ /// <param name="pipeline">The pipeline.</param>
956+ /// <param name="newRoot">The new root.</param>
957+ /// <returns>
958+ /// A new pipeline with an additional stage.
959+ /// </returns>
960+ public static PipelineDefinition < TInput , TOutput > ReplaceWith < TInput , TIntermediate , TOutput > (
961+ this PipelineDefinition < TInput , TIntermediate > pipeline ,
962+ AggregateExpressionDefinition < TIntermediate , TOutput > newRoot )
963+ {
964+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
965+ return pipeline . AppendStage ( PipelineStageDefinitionBuilder . ReplaceWith ( newRoot ) ) ;
966+ }
967+
968+ /// <summary>
969+ /// Appends a $replaceWith stage to the pipeline.
970+ /// </summary>
971+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
972+ /// <typeparam name="TIntermediate">The type of the intermediate documents.</typeparam>
973+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
974+ /// <param name="pipeline">The pipeline.</param>
975+ /// <param name="newRoot">The new root.</param>
976+ /// <param name="translationOptions">The translation options.</param>
977+ /// <returns>
978+ /// The fluent aggregate interface.
979+ /// </returns>
980+ public static PipelineDefinition < TInput , TOutput > ReplaceWith < TInput , TIntermediate , TOutput > (
981+ this PipelineDefinition < TInput , TIntermediate > pipeline ,
982+ Expression < Func < TIntermediate , TOutput > > newRoot ,
983+ ExpressionTranslationOptions translationOptions = null )
984+ {
985+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
986+ return pipeline . AppendStage ( PipelineStageDefinitionBuilder . ReplaceWith ( newRoot , translationOptions ) ) ;
987+ }
988+
949989 /// <summary>
950990 /// Appends a $skip stage to the pipeline.
951991 /// </summary>
0 commit comments