This commit is contained in:
@@ -10,52 +10,52 @@ namespace Ewide.Core.Data
|
||||
{
|
||||
public class DapperHelper : IDisposable
|
||||
{
|
||||
private readonly static string _connString = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnection"].ToString();
|
||||
private readonly static string _connString = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnection"]?.ToString();
|
||||
|
||||
public IDbConnection Sql = null;
|
||||
public IDbConnection Conn { get; } = null;
|
||||
|
||||
public DapperHelper()
|
||||
{
|
||||
Sql = new MySqlConnection(_connString);
|
||||
if (Sql.State == ConnectionState.Closed)
|
||||
Conn = new MySqlConnection(_connString);
|
||||
if (Conn.State == ConnectionState.Closed)
|
||||
{
|
||||
Sql.Open();
|
||||
Conn.Open();
|
||||
}
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
if (Sql.State == ConnectionState.Open)
|
||||
if (Conn.State == ConnectionState.Open)
|
||||
{
|
||||
Sql.Close();
|
||||
Conn.Close();
|
||||
}
|
||||
Sql.Dispose();
|
||||
Conn.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public class DapperTransactionHelper : IDisposable
|
||||
{
|
||||
private readonly static string _connString = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnection"].ToString();
|
||||
private readonly static string _connString = System.Configuration.ConfigurationManager.ConnectionStrings["MySqlConnection"]?.ToString();
|
||||
|
||||
public IDbConnection Sql = null;
|
||||
public IDbConnection Conn { get; } = null;
|
||||
|
||||
private IDbTransaction _trans = null;
|
||||
|
||||
public DapperTransactionHelper()
|
||||
{
|
||||
Sql = new MySqlConnection(_connString);
|
||||
if (Sql.State == ConnectionState.Closed)
|
||||
Conn = new MySqlConnection(_connString);
|
||||
if (Conn.State == ConnectionState.Closed)
|
||||
{
|
||||
Sql.Open();
|
||||
Conn.Open();
|
||||
}
|
||||
_trans = Sql.BeginTransaction();
|
||||
_trans = Conn.BeginTransaction();
|
||||
}
|
||||
|
||||
private void Close()
|
||||
{
|
||||
if (Sql.State == ConnectionState.Open)
|
||||
if (Conn.State == ConnectionState.Open)
|
||||
{
|
||||
Sql.Close();
|
||||
Conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Ewide.Core.Data
|
||||
{
|
||||
_trans.Dispose();
|
||||
this.Close();
|
||||
Sql.Dispose();
|
||||
Conn.Dispose();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
|
||||
Reference in New Issue
Block a user