mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 18:48:09 +08:00
Update mongodb
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using MongoDb.Ado.data;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MongoDb.Ado.data
|
||||
{
|
||||
public class ExecuteHandlerFactoryAsync
|
||||
{
|
||||
public readonly static Dictionary<string, IMongoOperationHandlerAsync> Items = new Dictionary<string, IMongoOperationHandlerAsync>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "insert", new InsertHandlerAsync() },
|
||||
{ "insertmany", new InsertManyHandlerAsync() },
|
||||
{ "update", new UpdateHandlerAsync() },
|
||||
{ "updatemany", new UpdateManyHandlerAsync() },
|
||||
{ "delete", new DeleteHandlerAsync() },
|
||||
{ "deletemany", new DeleteManyHandlerAsync() },
|
||||
{ "find", new NonFindHandlerAsync() }
|
||||
};
|
||||
|
||||
|
||||
public static Task<int> HandlerAsync(string operation, string json, IMongoCollection<BsonDocument> collection)
|
||||
{
|
||||
MongoDbMethodUtils.ValidateOperation(operation);
|
||||
var handlers = ExecuteHandlerFactoryAsync.Items;
|
||||
|
||||
if (!handlers.TryGetValue(operation, out var handler))
|
||||
throw new NotSupportedException($"不支持的操作类型: {operation}");
|
||||
handler.operation = operation;
|
||||
return handler.HandleAsync(collection, json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user