Update mongodb

This commit is contained in:
sunkaixuan
2025-06-10 17:51:49 +08:00
parent ea02771199
commit fffbe29151
4 changed files with 12 additions and 3 deletions

View File

@@ -6,12 +6,14 @@ using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace MongoDb.Ado.data
{
public class QueryAggregateHandlerAsync : IQueryHandlerAsync
{
public CancellationToken token { get; set; }
public async Task<DbDataReader> HandlerAsync(IMongoCollection<BsonDocument> collection, BsonValue doc)
{
// 解析 JSON 字符串为 BsonArray
@@ -21,7 +23,7 @@ namespace MongoDb.Ado.data
var aggregateFluent = collection.Aggregate<BsonDocument>(pipeline.Select(stage => new BsonDocument(stage.AsBsonDocument)).ToArray());
// 执行聚合查询并返回 DbDataReader
var cursor =await aggregateFluent.ToListAsync();
var cursor =await aggregateFluent.ToListAsync(token);
return new MongoDbBsonDocumentDataReader(cursor);
}
}