|
|
@ -219,28 +219,27 @@ public class SqlSugarDbContext : ISqlSugarDbContext
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnLogExecuting(string sql, SugarParameter[] pars)
|
|
|
|
protected virtual void OnLogExecuting(string sql, SugarParameter[] pars)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Options.EnabledSqlLog)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
|
|
|
sb.AppendLine("==========NPin-SQL==========");
|
|
|
|
|
|
|
|
sb.AppendLine(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
|
|
|
|
|
|
|
|
sb.AppendLine("============================");
|
|
|
|
|
|
|
|
Logger.CreateLogger<SqlSugarDbContext>().LogDebug(sb.ToString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnLogExecuted(string sql, SugarParameter[] pars)
|
|
|
|
protected virtual void OnLogExecuted(string sql, SugarParameter[] pars)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (Options.EnabledSqlLog)
|
|
|
|
if (Options.EnabledSqlLog)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var sqllog = $"=========NPin-SQL耗时{SqlSugarClient.Ado.SqlExecutionTime.TotalMilliseconds}毫秒=====";
|
|
|
|
var log = Logger.CreateLogger<SqlSugarDbContext>();
|
|
|
|
Logger.CreateLogger<SqlSugarDbContext>().LogDebug(sqllog);
|
|
|
|
|
|
|
|
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
sb.AppendLine();
|
|
|
|
|
|
|
|
sb.AppendLine("==========NPin-SQL==========");
|
|
|
|
|
|
|
|
sb.AppendLine(UtilMethods.GetNativeSql(sql, pars));
|
|
|
|
|
|
|
|
sb.AppendLine($"Count: {SqlSugarClient.Ado.SqlExecuteCount}");
|
|
|
|
|
|
|
|
sb.AppendLine($"耗时 {SqlSugarClient.Ado.SqlExecutionTime.TotalMilliseconds} 毫秒");
|
|
|
|
|
|
|
|
log.LogDebug(sb.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 实体配置
|
|
|
|
/// 实体配置
|
|
|
|
|
|
|
|
/// 自动 Nullable
|
|
|
|
/// 自动主键
|
|
|
|
/// 自动主键
|
|
|
|
/// 自动Ignore关联配置(导航)
|
|
|
|
/// 自动Ignore关联配置(导航)
|
|
|
|
/// 开启下划线
|
|
|
|
/// 开启下划线
|
|
|
@ -249,6 +248,12 @@ public class SqlSugarDbContext : ISqlSugarDbContext
|
|
|
|
/// <param name="column"></param>
|
|
|
|
/// <param name="column"></param>
|
|
|
|
protected virtual void EntityService(PropertyInfo property, EntityColumnInfo column)
|
|
|
|
protected virtual void EntityService(PropertyInfo property, EntityColumnInfo column)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// 自动 Nullable
|
|
|
|
|
|
|
|
if (new NullabilityInfoContext().Create(property).WriteState is NullabilityState.Nullable)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
column.IsNullable = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (property.PropertyType == typeof(ExtraPropertyDictionary))
|
|
|
|
if (property.PropertyType == typeof(ExtraPropertyDictionary))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
column.IsIgnore = true;
|
|
|
|
column.IsIgnore = true;
|
|
|
|