Update mongodb

This commit is contained in:
sunkaixuan
2025-05-02 11:39:41 +08:00
parent 5ec98af257
commit 8b1710b09e
9 changed files with 286 additions and 15 deletions

View File

@@ -0,0 +1,33 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
namespace MongoDb.Ado.data
{
public class DbDataReaderFactory
{
public DbDataReader Handle(string operation, IMongoCollection<BsonDocument> collection, string json)
{
var doc = MongoDB.Bson.Serialization.BsonSerializer.Deserialize<BsonValue>(json);
IQueryHandler queryHandler = null;
if (operation == "find")
{
queryHandler = new QueryFindHandler();
}
else if (operation == "aggregate")
{
queryHandler = new QueryAggregateHandler();
}
else
{
throw new NotSupportedException($" NotSupportedException: {operation} ");
}
return queryHandler.Find(collection, doc);
}
}
}