From 06469c528c4f097993c950c7ba4db0dc84960acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SAL=C4=B0H=20=C3=96ZKARA?= Date: Thu, 18 Dec 2025 17:56:55 +0300 Subject: [PATCH] Add provider check to SqliteBusyTimeout interceptor Updated SqliteBusyTimeoutSaveChangesInterceptor to execute the PRAGMA command only if the DbContext is using the Sqlite provider. This prevents unnecessary execution for non-Sqlite databases. --- .../SqliteBusyTimeoutSaveChangesInterceptor.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Interceptors/SqliteBusyTimeoutSaveChangesInterceptor.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Interceptors/SqliteBusyTimeoutSaveChangesInterceptor.cs index 32b4859bbb..1caada4592 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Interceptors/SqliteBusyTimeoutSaveChangesInterceptor.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Interceptors/SqliteBusyTimeoutSaveChangesInterceptor.cs @@ -19,7 +19,7 @@ public class SqliteBusyTimeoutSaveChangesInterceptor : SaveChangesInterceptor public override InterceptionResult SavingChanges(DbContextEventData eventData, InterceptionResult result) { - if (eventData.Context != null) + if (eventData.Context != null && IsSqlite(eventData.Context)) { eventData.Context.Database.ExecuteSqlRaw(_pragmaCommand); } @@ -29,11 +29,17 @@ public class SqliteBusyTimeoutSaveChangesInterceptor : SaveChangesInterceptor public override async ValueTask> SavingChangesAsync(DbContextEventData eventData, InterceptionResult result, CancellationToken cancellationToken = default) { - if (eventData.Context != null) + if (eventData.Context != null && IsSqlite(eventData.Context)) { await eventData.Context.Database.ExecuteSqlRawAsync(_pragmaCommand, cancellationToken: cancellationToken); } return await base.SavingChangesAsync(eventData, result, cancellationToken); } + + + private bool IsSqlite(DbContext context) + { + return context.Database.ProviderName != null && context.Database.ProviderName.Contains("Sqlite"); + } }