Skip to content

Commit

Permalink
Open the connection in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed May 4, 2023
1 parent 8449050 commit 7d9de18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/CookieTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public CookieTracker(CookieDatabaseContext databaseContext, IConfiguration confi

DatabaseContext = databaseContext;
NpgsqlConnection connection = (NpgsqlConnection)DatabaseContext.Database.GetDbConnection();
connection.Open();
DatabaseCommands = new Dictionary<DatabaseOperation, NpgsqlCommand>
{
[DatabaseOperation.Create] = GetInsertCommand(connection),
Expand Down Expand Up @@ -91,7 +92,6 @@ private async Task StartBakingAsync()
{
DbCommand createCommand = DatabaseCommands[DatabaseOperation.Create];
DbCommand updateCommand = DatabaseCommands[DatabaseOperation.Update];
await updateCommand.Connection!.OpenAsync();
foreach (DbCommand command in DatabaseCommands.Values)
{
await command.PrepareAsync();
Expand Down

0 comments on commit 7d9de18

Please sign in to comment.