-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACUtils.SqlDB2 1.0.0.142 - [bugfix] corretta gestione connessioni per…
…sistenti
- Loading branch information
1 parent
f10b1dc
commit 911855e
Showing
3 changed files
with
78 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using IBM.Data.DB2.iSeries; | ||
|
||
using System; | ||
|
||
|
||
namespace ACUtils | ||
{ | ||
public class ConnectionWrapper : IDisposable | ||
{ | ||
public readonly iDB2Connection Connection; | ||
private bool _closeOnDispose; | ||
public ConnectionWrapper(iDB2Connection connection, bool closeOnDispose = true) | ||
{ | ||
this.Connection = connection; | ||
_closeOnDispose = closeOnDispose; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
if (_closeOnDispose) | ||
{ | ||
if (Connection?.State == System.Data.ConnectionState.Open) | ||
{ | ||
Connection.Close(); | ||
} | ||
Connection?.Dispose(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters