From f97f23c8a527fb3b3d3df98c45ad55b626bfc65c Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 25 Jan 2024 10:45:02 +0900 Subject: [PATCH] Do not dispose connections created by EF --- BTCPayServer/Services/WalletRepository.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/BTCPayServer/Services/WalletRepository.cs b/BTCPayServer/Services/WalletRepository.cs index ba71519b0..1ca22c155 100644 --- a/BTCPayServer/Services/WalletRepository.cs +++ b/BTCPayServer/Services/WalletRepository.cs @@ -393,8 +393,7 @@ namespace BTCPayServer.Services } else { - var conn = ctx.Database.GetDbConnection(); - await conn.ExecuteAsync("INSERT INTO \"WalletObjectLinks\" VALUES (@WalletId, @AType, @AId, @BType, @BId, @Data::JSONB) ON CONFLICT DO NOTHING", links); + await connection.ExecuteAsync("INSERT INTO \"WalletObjectLinks\" VALUES (@WalletId, @AType, @AId, @BType, @BId, @Data::JSONB) ON CONFLICT DO NOTHING", links); } } @@ -700,11 +699,9 @@ namespace BTCPayServer.Services walletObjectLinks ??= new List(); var objs = walletObjects.Concat(ExtractObjectsFromLinks(walletObjectLinks).Except(walletObjects)).ToArray(); await using var ctx = _ContextFactory.CreateContext(); - await using var connection = ctx.Database.GetDbConnection(); - await connection.OpenAsync(); + var connection = ctx.Database.GetDbConnection(); await EnsureWalletObjects(ctx,connection, objs); await EnsureWalletObjectLinks(ctx,connection, walletObjectLinks); - await connection.CloseAsync(); } #nullable restore }