@@ -27,7 +27,7 @@ public class MongoDbService : IGameDbService
2727 /// </summary>
2828 /// <param name="url">MongoDB连接URL。</param>
2929 /// <param name="dbName">要使用的数据库名称。</param>
30- public async void Open ( string url , string dbName )
30+ public void Open ( string url , string dbName )
3131 {
3232 try
3333 {
@@ -47,11 +47,12 @@ public async void Open(string url, string dbName)
4747 /// 获取指定类型的MongoDB集合。
4848 /// </summary>
4949 /// <typeparam name="TState">文档的类型。</typeparam>
50+ /// <param name="settings">集合的设置。</param>
5051 /// <returns>指定类型的MongoDB集合。</returns>
51- private IMongoCollection < TState > GetCollection < TState > ( ) where TState : ICacheState , new ( )
52+ private IMongoCollection < TState > GetCollection < TState > ( MongoCollectionSettings settings = null ) where TState : ICacheState , new ( )
5253 {
5354 var collectionName = typeof ( TState ) . Name ;
54- IMongoCollection < TState > ? collection = CurrentDatabase . GetCollection < TState > ( collectionName ) ;
55+ IMongoCollection < TState > collection = CurrentDatabase . GetCollection < TState > ( collectionName , settings ) ;
5556 return collection ;
5657 }
5758
@@ -303,7 +304,7 @@ public async void Open(string url, string dbName)
303304 /// </summary>
304305 /// <param name="states"></param>
305306 /// <typeparam name="TState"></typeparam>
306- public async Task AddListAsync < TState > ( List < TState > states ) where TState : ICacheState , new ( )
307+ public async Task AddListAsync < TState > ( List < TState > states ) where TState : class , ICacheState , new ( )
307308 {
308309 var collection = GetCollection < TState > ( ) ;
309310 var cacheStates = states . ToList ( ) ;
0 commit comments