Skip to content

Commit

Permalink
Improve Open and Close to take into account the current state of the …
Browse files Browse the repository at this point in the history
…connection.
  • Loading branch information
NimaAra committed Jan 27, 2019
1 parent 8e600d8 commit f9016a3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Easy.Storage.SQLite/Connections/SqliteConnectionBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,15 @@ protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLeve
/// <summary>
/// When the database connection is closed, all commands linked to this connection are automatically reset.
/// </summary>
public override void Close() => Connection.Close();
public override void Close()
{
if (Connection.State == ConnectionState.Closed)
{
return;
}

Connection.Close();
}

/// <summary>
/// This method is not implemented; however, the <c>Changed</c> event will still be raised.
Expand All @@ -103,7 +111,12 @@ protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLeve
/// <summary>
/// Opens the connection using the parameters found in the <see cref="ConnectionString"/>.
/// </summary>
public override void Open() => Connection.Open();
public override void Open()
{
if (Connection.State == ConnectionState.Open) { return; }

Connection.Open();
}

/// <summary>
/// Opens and returns the connection using the parameters found in the <see cref="ConnectionString"/>.
Expand Down

0 comments on commit f9016a3

Please sign in to comment.