mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-24 00:49:31 +08:00
34 lines
982 B
C#
34 lines
982 B
C#
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);
|
|
}
|
|
|
|
}
|
|
}
|