From 7373763e9f4b58d56a65c90802b9b439805f6a5b Mon Sep 17 00:00:00 2001 From: xuejiaming <326308290@qq.com> Date: Fri, 10 Feb 2023 22:46:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Dispose=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B8=85=E6=A5=9A=E7=BC=93=E5=AD=98=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sharding/ShardingDbContextExecutors/DataSourceDbContext.cs | 2 ++ .../ShardingDbContextExecutors/ShardingDbContextExecutor.cs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/ShardingCore/Sharding/ShardingDbContextExecutors/DataSourceDbContext.cs b/src/ShardingCore/Sharding/ShardingDbContextExecutors/DataSourceDbContext.cs index a56a52d2..4510461e 100644 --- a/src/ShardingCore/Sharding/ShardingDbContextExecutors/DataSourceDbContext.cs +++ b/src/ShardingCore/Sharding/ShardingDbContextExecutors/DataSourceDbContext.cs @@ -428,6 +428,7 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors { dataSourceDbContext.Value.Dispose(); } + _dataSourceDbContexts.Clear(); } #if !EFCORE2 public async ValueTask DisposeAsync() @@ -436,6 +437,7 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors { await dataSourceDbContext.Value.DisposeAsync(); } + _dataSourceDbContexts.Clear(); } #endif } diff --git a/src/ShardingCore/Sharding/ShardingDbContextExecutors/ShardingDbContextExecutor.cs b/src/ShardingCore/Sharding/ShardingDbContextExecutors/ShardingDbContextExecutor.cs index 5fb4e0a7..b8ef76cb 100644 --- a/src/ShardingCore/Sharding/ShardingDbContextExecutors/ShardingDbContextExecutor.cs +++ b/src/ShardingCore/Sharding/ShardingDbContextExecutors/ShardingDbContextExecutor.cs @@ -279,6 +279,7 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors { dbContextCache.Value.Dispose(); } + _dbContextCaches.Clear(); } #if !EFCORE2 @@ -374,6 +375,7 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors { await dbContextCache.Value.DisposeAsync(); } + _dbContextCaches.Clear(); } #endif