only open connection if it's closed.

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-02-10 11:19:27 -07:00
parent 46a227453e
commit d3f94337ae
17 changed files with 72 additions and 18 deletions

View File

@@ -16,7 +16,10 @@ namespace CarCareTracker.External.Implementations
_logger = logger;
try
{
pgDataSource.Open();
if (pgDataSource.State == System.Data.ConnectionState.Closed)
{
pgDataSource.Open();
}
//create table if not exist.
string initCMD = $"CREATE TABLE IF NOT EXISTS app.{tableName} (id INT primary key, data jsonb not null)";
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))