diff --git a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDBExtensions.cs b/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDBExtensions.cs deleted file mode 100644 index 734e5346..00000000 --- a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDBExtensions.cs +++ /dev/null @@ -1,21 +0,0 @@ -using MongoDB.Driver; - -namespace GameFrameX.DBServer.DbService.MongoDB; - -/// -/// MongoDB扩展 -/// -public static class MongoDbExtensions -{ - /// - /// 获取指定类型的MongoDB集合。 - /// - /// 文档的类型。 - /// 要操作的MongoDB数据库。 - /// 集合的设置。 - /// 指定类型的MongoDB集合。 - public static IMongoCollection GetCollection(this IMongoDatabase self, MongoCollectionSettings settings = null) - { - return self.GetCollection(typeof(TDocument).FullName, settings); - } -} \ No newline at end of file diff --git a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs b/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs index 1264c7b7..93509b61 100644 --- a/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs +++ b/DataBaseServer/GameFrameX.DBServer/DbService/MongoDB/MongoDbService.cs @@ -27,7 +27,7 @@ public class MongoDbService : IGameDbService /// /// MongoDB连接URL。 /// 要使用的数据库名称。 - public async void Open(string url, string dbName) + public void Open(string url, string dbName) { try { @@ -47,11 +47,12 @@ public async void Open(string url, string dbName) /// 获取指定类型的MongoDB集合。 /// /// 文档的类型。 + /// 集合的设置。 /// 指定类型的MongoDB集合。 - private IMongoCollection GetCollection() where TState : ICacheState, new() + private IMongoCollection GetCollection(MongoCollectionSettings settings = null) where TState : ICacheState, new() { var collectionName = typeof(TState).Name; - IMongoCollection? collection = CurrentDatabase.GetCollection(collectionName); + IMongoCollection collection = CurrentDatabase.GetCollection(collectionName, settings); return collection; } @@ -303,7 +304,7 @@ public async void Open(string url, string dbName) /// /// /// - public async Task AddListAsync(List states) where TState : ICacheState, new() + public async Task AddListAsync(List states) where TState : class, ICacheState, new() { var collection = GetCollection(); var cacheStates = states.ToList(); diff --git a/DataBaseServer/GameFrameX.DBServer/GameFrameX.DBServer.csproj b/DataBaseServer/GameFrameX.DBServer/GameFrameX.DBServer.csproj index b3a4953a..99610827 100644 --- a/DataBaseServer/GameFrameX.DBServer/GameFrameX.DBServer.csproj +++ b/DataBaseServer/GameFrameX.DBServer/GameFrameX.DBServer.csproj @@ -3,7 +3,7 @@ net8.0 enable - enable + disable GameFrameX.DBServer GameFrameX,Lib,DBServer,Server,GameServer true