only open connection if it's closed.
This commit is contained in:
@@ -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 GENERATED BY DEFAULT AS IDENTITY primary key, vehicleId INT not null, data jsonb not null)";
|
||||
using (var ctext = new NpgsqlCommand(initCMD, pgDataSource))
|
||||
|
||||
Reference in New Issue
Block a user