Update Mongodb

This commit is contained in:
sunkaixuan
2025-05-02 15:42:18 +08:00
parent bad7a86c23
commit 54264afde5
2 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,6 @@
using MongoDb.Ado.data;
using MongoDB.Bson;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Text;
@@ -17,5 +19,17 @@ namespace MongoDb.Ado.data
{ "deletemany", new DeleteManyHandler() },
{ "find", new NonFindHandler() }
};
public static int Handler(string operation, string json, IMongoCollection<BsonDocument> collection)
{
var handlers = ExecuteHandlerFactory.Items;
if (!handlers.TryGetValue(operation, out var handler))
throw new NotSupportedException($"不支持的操作类型: {operation}");
return handler.Handle(collection, json);
}
}
}

View File

@@ -57,14 +57,8 @@ namespace MongoDb.Ado.data
public override int ExecuteNonQuery()
{
var (operation, collectionName, json) = ParseCommand(_commandText);
var collection = GetCollection(collectionName);
var handlers = ExecuteHandlerFactory.Items;
if (!handlers.TryGetValue(operation, out var handler))
throw new NotSupportedException($"不支持的操作类型: {operation}");
return handler.Handle(collection, json);
var collection = GetCollection(collectionName);
return ExecuteHandlerFactory.Handler(operation, json, collection);
}
public override object ExecuteScalar()