Browse Source
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.
pull/24448/head
SALİH ÖZKARA
5 months ago
committed by
maliming
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
8 additions and
2 deletions
framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Interceptors/SqliteBusyTimeoutSaveChangesInterceptor.cs
@ -19,7 +19,7 @@ public class SqliteBusyTimeoutSaveChangesInterceptor : SaveChangesInterceptor
public override InterceptionResult < int > SavingChanges ( DbContextEventData eventData , InterceptionResult < int > 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 < InterceptionResult < int > > SavingChangesAsync ( DbContextEventData eventData , InterceptionResult < int > 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" ) ;
}
}