diff --git a/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs b/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs index bdf2463de74..840c9179eb1 100644 --- a/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs +++ b/src/Microsoft.Data.Sqlite.Core/SqliteConnection.cs @@ -40,6 +40,9 @@ public partial class SqliteConnection : DbConnection private bool _extensionsEnabled; private int? _defaultTimeout; + private static readonly StateChangeEventArgs _fromClosedToOpenEventArgs = new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open); + private static readonly StateChangeEventArgs _fromOpenToClosedEventArgs = new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed); + static SqliteConnection() => BundleInitializer.Initialize(); @@ -287,7 +290,7 @@ public override void Open() throw; } - OnStateChange(new StateChangeEventArgs(ConnectionState.Closed, ConnectionState.Open)); + OnStateChange(_fromClosedToOpenEventArgs); } /// @@ -322,7 +325,7 @@ public override void Close() _innerConnection = null; _state = ConnectionState.Closed; - OnStateChange(new StateChangeEventArgs(ConnectionState.Open, ConnectionState.Closed)); + OnStateChange(_fromOpenToClosedEventArgs); } internal void Deactivate()