Code optimization

This commit is contained in:
skx
2021-02-03 17:50:54 +08:00
parent 0c61f19b30
commit d5014ef582

View File

@@ -91,7 +91,6 @@ namespace SqlSugar
{ {
File.Delete(fileName); File.Delete(fileName);
} }
conn.Close();
} }
catch (MySqlException ex) catch (MySqlException ex)
{ {
@@ -99,7 +98,7 @@ namespace SqlSugar
} }
finally finally
{ {
this.Context.Ado.Close(); CloseDb();
} }
return IsBulkLoad; ; return IsBulkLoad; ;
} }
@@ -109,6 +108,15 @@ namespace SqlSugar
return Task.FromResult(ExecuteBlueCopy()); return Task.FromResult(ExecuteBlueCopy());
} }
private void CloseDb()
{
if (this.Context.CurrentConnectionConfig.IsAutoCloseConnection && this.Context.Ado.Transaction == null)
{
this.Context.Ado.Connection.Close();
}
}
/// <summary> /// <summary>
///DataTable to CSV ///DataTable to CSV
/// </summary> /// </summary>