diff --git a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/Tools/UtilMethods.cs b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/Tools/UtilMethods.cs
index 5f7053b29..c8e6a3e05 100644
--- a/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/Tools/UtilMethods.cs
+++ b/Src/Asp.NetCore2/SqlSugar.TDSQLForPGODBC/Tools/UtilMethods.cs
@@ -601,6 +601,8 @@ namespace SqlSugar.TDSQLForPGODBC
DataExecuted = it.AopEvents?.DataExecuted,
CheckConnectionExecuted = it.AopEvents?.CheckConnectionExecuted,
CheckConnectionExecuting = it.AopEvents?.CheckConnectionExecuting,
+ OnGetDataReadered = it.AopEvents?.OnGetDataReadered,
+ OnGetDataReadering = it.AopEvents?.OnGetDataReadering,
},
ConfigId = it.ConfigId,
ConfigureExternalServices = it.ConfigureExternalServices == null ? null : new ConfigureExternalServices()
diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
index 028ddf298..94058536b 100644
--- a/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
+++ b/Src/Asp.NetCore2/SqlSugar/Abstract/AdoProvider/AdoProvider.cs
@@ -40,6 +40,7 @@ namespace SqlSugar
public IDataParameterCollection DataReaderParameters { get; set; }
public TimeSpan SqlExecutionTime { get { return AfterTime - BeforeTime; } }
public TimeSpan ConnectionExecutionTime { get { return CheckConnectionAfterTime - CheckConnectionBeforeTime; } }
+ public TimeSpan GetDataExecutionTime { get { return GetDataAfterTime - GetDataBeforeTime; } }
///
/// Add, delete and modify: the number of affected items;
///
@@ -48,6 +49,8 @@ namespace SqlSugar
public bool IsDisableMasterSlaveSeparation { get; set; }
internal DateTime BeforeTime = DateTime.MinValue;
internal DateTime AfterTime = DateTime.MinValue;
+ internal DateTime GetDataBeforeTime = DateTime.MinValue;
+ internal DateTime GetDataAfterTime = DateTime.MinValue;
internal DateTime CheckConnectionBeforeTime = DateTime.MinValue;
internal DateTime CheckConnectionAfterTime = DateTime.MinValue;
public virtual IDbBind DbBind
@@ -71,6 +74,8 @@ namespace SqlSugar
public virtual Action LogEventCompleted => this.Context.CurrentConnectionConfig.AopEvents?.OnLogExecuted;
public virtual Action CheckConnectionExecuting => this.Context.CurrentConnectionConfig.AopEvents?.CheckConnectionExecuting;
public virtual Action CheckConnectionExecuted => this.Context.CurrentConnectionConfig.AopEvents?.CheckConnectionExecuted;
+ public virtual Action OnGetDataReadering => this.Context.CurrentConnectionConfig.AopEvents?.OnGetDataReadering;
+ public virtual Action OnGetDataReadered => this.Context.CurrentConnectionConfig.AopEvents?.OnGetDataReadered;
public virtual Func> ProcessingEventStartingSQL => this.Context.CurrentConnectionConfig.AopEvents?.OnExecutingChangeSql;
protected virtual Func FormatSql { get; set; }
public virtual Action ErrorEvent => this.Context.CurrentConnectionConfig.AopEvents?.OnError;
@@ -1048,7 +1053,10 @@ namespace SqlSugar
builder.SqlQueryBuilder.sql.Append(sql);
if (parsmeterArray != null && parsmeterArray.Any())
builder.SqlQueryBuilder.Parameters.AddRange(parsmeterArray);
- using (var dataReader = this.GetDataReader(builder.SqlQueryBuilder.ToSqlString(), builder.SqlQueryBuilder.Parameters.ToArray()))
+ string sqlString = builder.SqlQueryBuilder.ToString();
+ SugarParameter[] Parameters = builder.SqlQueryBuilder.Parameters.ToArray();
+ this.GetDataBefore(sqlString, Parameters);
+ using (var dataReader = this.GetDataReader(sqlString, Parameters))
{
DbDataReader DbReader = (DbDataReader)dataReader;
List result = new List();
@@ -1109,6 +1117,7 @@ namespace SqlSugar
}
this.Context.Ado.DataReaderParameters = null;
}
+ this.GetDataAfter(sqlString, Parameters);
return Tuple.Create, List, List, List, List, List, List>(result, result2, result3, result4, result5, result6, result7);
}
}
@@ -1173,7 +1182,10 @@ namespace SqlSugar
builder.SqlQueryBuilder.sql.Append(sql);
if (parsmeterArray != null && parsmeterArray.Any())
builder.SqlQueryBuilder.Parameters.AddRange(parsmeterArray);
- using (var dataReader = await this.GetDataReaderAsync(builder.SqlQueryBuilder.ToSqlString(), builder.SqlQueryBuilder.Parameters.ToArray()))
+ string sqlString = builder.SqlQueryBuilder.ToSqlString();
+ SugarParameter[] Parameters = builder.SqlQueryBuilder.Parameters.ToArray();
+ this.GetDataBefore(sqlString, Parameters);
+ using (var dataReader = await this.GetDataReaderAsync(sqlString, Parameters))
{
DbDataReader DbReader = (DbDataReader)dataReader;
List result = new List();
@@ -1230,6 +1242,7 @@ namespace SqlSugar
}
this.Context.Ado.DataReaderParameters = null;
}
+ this.GetDataAfter(sqlString, Parameters);
return Tuple.Create, List, List, List, List, List, List>(result, result2, result3, result4, result5, result6, result7);
}
}
@@ -1584,6 +1597,44 @@ namespace SqlSugar
this.OldClearParameters = false;
}
}
+ public virtual void GetDataBefore(string sql, SugarParameter[] parameters)
+ {
+ this.GetDataBeforeTime = DateTime.Now;
+ if (this.IsEnableLogEvent)
+ {
+ Action action = OnGetDataReadering;
+ if (action != null)
+ {
+ if (parameters == null || parameters.Length == 0)
+ {
+ action(sql, new SugarParameter[] { });
+ }
+ else
+ {
+ action(sql, parameters);
+ }
+ }
+ }
+ }
+ public virtual void GetDataAfter(string sql, SugarParameter[] parameters)
+ {
+ this.GetDataAfterTime = DateTime.Now;
+ if (this.IsEnableLogEvent)
+ {
+ Action action = OnGetDataReadered;
+ if (action != null)
+ {
+ if (parameters == null || parameters.Length == 0)
+ {
+ action(sql, new SugarParameter[] { }, GetDataExecutionTime);
+ }
+ else
+ {
+ action(sql, parameters, GetDataExecutionTime);
+ }
+ }
+ }
+ }
public virtual SugarParameter[] GetParameters(object parameters, PropertyInfo[] propertyInfo = null)
{
if (parameters == null) return null;
diff --git a/Src/Asp.NetCore2/SqlSugar/Abstract/AopProvider/AopProvider.cs b/Src/Asp.NetCore2/SqlSugar/Abstract/AopProvider/AopProvider.cs
index 0055b586f..aee0d3e54 100644
--- a/Src/Asp.NetCore2/SqlSugar/Abstract/AopProvider/AopProvider.cs
+++ b/Src/Asp.NetCore2/SqlSugar/Abstract/AopProvider/AopProvider.cs
@@ -25,5 +25,7 @@ namespace SqlSugar
public virtual Action