mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-03 12:18:00 +08:00
-
This commit is contained in:
parent
2cf85ba888
commit
54b082e75b
@ -227,16 +227,26 @@ namespace SqlSugar
|
|||||||
#region Core
|
#region Core
|
||||||
public virtual int ExecuteCommand(string sql, params SugarParameter[] parameters)
|
public virtual int ExecuteCommand(string sql, params SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
try
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
{
|
||||||
ExecuteBefore(sql, parameters);
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
int count = sqlCommand.ExecuteNonQuery();
|
ExecuteBefore(sql, parameters);
|
||||||
if (this.IsClearParameters)
|
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
||||||
sqlCommand.Parameters.Clear();
|
int count = sqlCommand.ExecuteNonQuery();
|
||||||
ExecuteAfter(sql, parameters);
|
if (this.IsClearParameters)
|
||||||
if (this.IsClose()) this.Close();
|
sqlCommand.Parameters.Clear();
|
||||||
return count;
|
ExecuteAfter(sql, parameters);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (this.IsClose()) this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual IDataReader GetDataReader(string sql, params SugarParameter[] parameters)
|
public virtual IDataReader GetDataReader(string sql, params SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
@ -255,33 +265,53 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual DataSet GetDataSetAll(string sql, params SugarParameter[] parameters)
|
public virtual DataSet GetDataSetAll(string sql, params SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
try
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
{
|
||||||
ExecuteBefore(sql, parameters);
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
IDataAdapter dataAdapter = this.GetAdapter();
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
ExecuteBefore(sql, parameters);
|
||||||
this.SetCommandToAdapter(dataAdapter, sqlCommand);
|
IDataAdapter dataAdapter = this.GetAdapter();
|
||||||
DataSet ds = new DataSet();
|
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
||||||
dataAdapter.Fill(ds);
|
this.SetCommandToAdapter(dataAdapter, sqlCommand);
|
||||||
if (this.IsClearParameters)
|
DataSet ds = new DataSet();
|
||||||
sqlCommand.Parameters.Clear();
|
dataAdapter.Fill(ds);
|
||||||
ExecuteAfter(sql, parameters);
|
if (this.IsClearParameters)
|
||||||
if (this.IsClose()) this.Close();
|
sqlCommand.Parameters.Clear();
|
||||||
return ds;
|
ExecuteAfter(sql, parameters);
|
||||||
|
return ds;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (this.IsClose()) this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public virtual object GetScalar(string sql, params SugarParameter[] parameters)
|
public virtual object GetScalar(string sql, params SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
if (this.ProcessingEventStartingSQL != null)
|
try
|
||||||
ExecuteProcessingSQL(ref sql, parameters);
|
{
|
||||||
ExecuteBefore(sql, parameters);
|
if (this.ProcessingEventStartingSQL != null)
|
||||||
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
ExecuteProcessingSQL(ref sql, parameters);
|
||||||
object scalar = sqlCommand.ExecuteScalar();
|
ExecuteBefore(sql, parameters);
|
||||||
scalar = (scalar == null ? 0 : scalar);
|
IDbCommand sqlCommand = GetCommand(sql, parameters);
|
||||||
if (this.IsClearParameters)
|
object scalar = sqlCommand.ExecuteScalar();
|
||||||
sqlCommand.Parameters.Clear();
|
scalar = (scalar == null ? 0 : scalar);
|
||||||
ExecuteAfter(sql, parameters);
|
if (this.IsClearParameters)
|
||||||
if (this.IsClose()) this.Close();
|
sqlCommand.Parameters.Clear();
|
||||||
return scalar;
|
ExecuteAfter(sql, parameters);
|
||||||
|
return scalar;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (this.IsClose()) this.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user