@ -19,7 +19,7 @@ public class SqliteBusyTimeoutSaveChangesInterceptor : SaveChangesInterceptor
public override InterceptionResult < int > SavingChanges ( DbContextEventData eventData , InterceptionResult < int > result )
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 ) ;
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 )
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 ) ;
await eventData . Context . Database . ExecuteSqlRawAsync ( _ pragmaCommand , cancellationToken : cancellationToken ) ;
}
}
return await base . SavingChangesAsync ( eventData , result , cancellationToken ) ;
return await base . SavingChangesAsync ( eventData , result , cancellationToken ) ;
}
}
private bool IsSqlite ( DbContext context )
{
return context . Database . ProviderName ! = null & & context . Database . ProviderName . Contains ( "Sqlite" ) ;
}
}
}