SqlSugar/Src/Asp.NetCore2/MongoDb.Ado.data/ExecuteNonQueryItemsAsync/InsertHandlerAsync.cs

20 lines
492 B
C#
Raw Normal View History

2025-05-02 16:30:22 +08:00
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 InsertHandlerAsync : IMongoOperationHandlerAsync
{
public async Task<int> HandleAsync(IMongoCollection<BsonDocument> collection, string json)
{
var doc = BsonDocument.Parse(json);
await collection.InsertOneAsync(doc);
return 1;
}
}
}