File tree Expand file tree Collapse file tree
GameFrameX.DataBase.Mongo
GameFrameX.DataBase/Abstractions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ public sealed partial class MongoDbService : IDatabaseService
5252 /// </summary>
5353 public IMongoDatabase CurrentDatabase { get ; private set ; }
5454
55+ private DbOptions _dbOptions ;
5556 private MongoDbContext _mongoDbContext ;
5657
5758 /// <summary>
@@ -61,10 +62,12 @@ public sealed partial class MongoDbService : IDatabaseService
6162 /// <returns>返回数据库是否初始化成功</returns>
6263 public async Task < bool > Open ( DbOptions dbOptions )
6364 {
65+ ArgumentNullException . ThrowIfNull ( dbOptions , nameof ( dbOptions ) ) ;
66+ ArgumentNullException . ThrowIfNull ( dbOptions . ConnectionString , nameof ( dbOptions . ConnectionString ) ) ;
67+ ArgumentNullException . ThrowIfNull ( dbOptions . Name , nameof ( dbOptions . Name ) ) ;
68+ _dbOptions = dbOptions ;
6469 try
6570 {
66- ArgumentNullException . ThrowIfNull ( dbOptions . ConnectionString , nameof ( dbOptions . ConnectionString ) ) ;
67- ArgumentNullException . ThrowIfNull ( dbOptions . Name , nameof ( dbOptions . Name ) ) ;
6871 var settings = MongoClientSettings . FromConnectionString ( dbOptions . ConnectionString ) ;
6972 var db = await DB . InitAsync ( dbOptions . Name , settings ) ;
7073 _mongoDbContext = new MongoDbContext ( dbOptions . Name ) ;
Original file line number Diff line number Diff line change @@ -51,4 +51,9 @@ public sealed record DbOptions
5151 /// 数据库名称
5252 /// </summary>
5353 public string Name { get ; init ; }
54+
55+ /// <summary>
56+ /// 是否使用时区时间记录
57+ /// </summary>
58+ public bool IsUseTimeZone { get ; init ; } = true ;
5459}
You can’t perform that action at this time.
0 commit comments