优化代码生成
This commit is contained in:
@@ -32,7 +32,7 @@ namespace ZR.Admin.WebApi
|
||||
Configuration = configuration;
|
||||
CurrentEnvironment = hostEnvironment;
|
||||
}
|
||||
|
||||
private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
private IWebHostEnvironment CurrentEnvironment { get; }
|
||||
public IConfiguration Configuration { get; }
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
@@ -167,13 +167,14 @@ namespace ZR.Admin.WebApi
|
||||
});
|
||||
|
||||
//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡSQL
|
||||
DbScoped.SugarScope.GetConnection("0").Aop.OnLogExecuting = (sql, pars) =>
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine("<22><>SQL<51><4C><EFBFBD>䡿" + sql.ToLower() + "\r\n"
|
||||
+ DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
//Console.WriteLine("<22><>SQL<51><4C><EFBFBD>䡿" + sql.ToLower() + "\r\n" + param);
|
||||
logger.Info($"Sql<71><6C><EFBFBD>䣺{sql}<7D><>{param}");
|
||||
};
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1>־
|
||||
DbScoped.SugarScope.GetConnection("0").Aop.OnError = (e) =>
|
||||
DbScoped.SugarScope.GetConnection(0).Aop.OnError = (e) =>
|
||||
{
|
||||
Console.WriteLine($"[ִ<><D6B4>Sql<71><6C><EFBFBD><EFBFBD>]{e.Message}<7D><>SQL={e.Sql}");
|
||||
Console.WriteLine();
|
||||
@@ -182,14 +183,14 @@ namespace ZR.Admin.WebApi
|
||||
//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡSQL
|
||||
DbScoped.SugarScope.GetConnection(1).Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine("<22><>SQL<51><4C><EFBFBD><EFBFBD>Bus<75><73>" + sql.ToLower() + "\r\n"
|
||||
+ DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
var param = DbScoped.SugarScope.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
|
||||
//Console.WriteLine("<22><>SQL<51><4C><EFBFBD><EFBFBD>Bus<75><73>" + sql.ToLower() + "\r\n" + param);
|
||||
logger.Info($"Sql<71><6C><EFBFBD>䣺{sql}, {param}");
|
||||
};
|
||||
//Bus Db<44><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
||||
DbScoped.SugarScope.GetConnection(1).Aop.OnError = (e) =>
|
||||
{
|
||||
Console.WriteLine($"[ִ<EFBFBD><EFBFBD>Sql<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Bus]{e.Message}<7D><>SQL={e.Sql}");
|
||||
Console.WriteLine();
|
||||
logger.Error($"ִ<><D6B4>Sql<71><6C><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>{e.Sql}<7D><>ԭ<EFBFBD><D4AD><EFBFBD><EFBFBD>{e.Message}");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user