Merge pull request #2 from SergioMatias94/feature/add-aggregate-pipeline
Add FindOnePipelineAsync method
This commit is contained in:
		| @@ -148,5 +148,13 @@ namespace Core.Blueprint.Mongo | |||||||
|         /// <param name="filterExpression">An expression used to filter the documents to delete.</param> |         /// <param name="filterExpression">An expression used to filter the documents to delete.</param> | ||||||
|         /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> |         /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> | ||||||
|         Task DeleteManyAsync(Expression<Func<TDocument, bool>> filterExpression); |         Task DeleteManyAsync(Expression<Func<TDocument, bool>> filterExpression); | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Executes an aggregation pipeline and returns the first document in the result asynchronously. | ||||||
|  |         /// </summary> | ||||||
|  |         /// <typeparam name="TOutput">The type of the output document you expect from the pipeline.</typeparam> | ||||||
|  |         /// <param name="pipeline">The aggregation pipeline definition to execute.</param> | ||||||
|  |         /// <returns>The first document from the aggregation result, or null if none found.</returns> | ||||||
|  |         Task<TOutput> FindOnePipelineAsync<TOutput>(PipelineDefinition<TDocument, TOutput> pipeline); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -248,5 +248,16 @@ namespace Core.Blueprint.Mongo | |||||||
|         { |         { | ||||||
|             return Task.Run(() => _collection.DeleteManyAsync(filterExpression)); |             return Task.Run(() => _collection.DeleteManyAsync(filterExpression)); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         /// <summary> | ||||||
|  |         /// Executes an aggregation pipeline and returns the first document in the result asynchronously. | ||||||
|  |         /// </summary> | ||||||
|  |         /// <typeparam name="TOutput">The type of the output document you expect from the pipeline.</typeparam> | ||||||
|  |         /// <param name="pipeline">The aggregation pipeline definition to execute.</param> | ||||||
|  |         /// <returns>The first document from the aggregation result, or null if none found.</returns> | ||||||
|  |         public virtual Task<TOutput> FindOnePipelineAsync<TOutput>(PipelineDefinition<TDocument, TOutput> pipeline) | ||||||
|  |         { | ||||||
|  |             return Task.Run(() => _collection.Aggregate(pipeline).FirstOrDefaultAsync()); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 GitHub
						GitHub