@@ -27,7 +27,7 @@ public class MongoDbService : IGameDbService
27
27
/// </summary>
28
28
/// <param name="url">MongoDB连接URL。</param>
29
29
/// <param name="dbName">要使用的数据库名称。</param>
30
- public async void Open ( string url , string dbName )
30
+ public void Open ( string url , string dbName )
31
31
{
32
32
try
33
33
{
@@ -47,11 +47,12 @@ public async void Open(string url, string dbName)
47
47
/// 获取指定类型的MongoDB集合。
48
48
/// </summary>
49
49
/// <typeparam name="TState">文档的类型。</typeparam>
50
+ /// <param name="settings">集合的设置。</param>
50
51
/// <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 ( )
52
53
{
53
54
var collectionName = typeof ( TState ) . Name ;
54
- IMongoCollection < TState > ? collection = CurrentDatabase . GetCollection < TState > ( collectionName ) ;
55
+ IMongoCollection < TState > collection = CurrentDatabase . GetCollection < TState > ( collectionName , settings ) ;
55
56
return collection ;
56
57
}
57
58
@@ -303,7 +304,7 @@ public async void Open(string url, string dbName)
303
304
/// </summary>
304
305
/// <param name="states"></param>
305
306
/// <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 ( )
307
308
{
308
309
var collection = GetCollection < TState > ( ) ;
309
310
var cacheStates = states . ToList ( ) ;
0 commit comments