增加视图模型引擎模块

This commit is contained in:
2023-08-02 17:52:00 +08:00
parent a07b3c73fc
commit ec69cc94e8
31 changed files with 3362 additions and 33 deletions

View File

@@ -30,37 +30,43 @@ public static class ConfigureSqlSugarExtensions
InitKeyType = InitKeyType.Attribute,
MoreSettings = new ConnMoreSettings()
{
IsAutoRemoveDataCache = true // 自动清理缓存
IsAutoRemoveDataCache = true, // 自动清理缓存
IsAutoToUpper = false,
//PgSqlIsAutoToLower = false,
DisableNvarchar = true
},
});
services.AddSqlSugar(connectConfigList, client =>
{
connectConfigList.ForEach(config =>
{
var db = ((SqlSugarScope)client).GetConnectionScope((string)config.ConfigId);
//connectConfigList.ForEach(config =>
//{
// var db = ((SqlSugarScope)client).GetConnectionScope((string)config.ConfigId);
// 设置超时时间
db.Ado.CommandTimeOut = 30;
//db.Aop.OnLogExecuted = (sql, pars) =>
//{
// var oldColor = Console.ForegroundColor;
// Console.ForegroundColor = ConsoleColor.Green;
// var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
// Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
// Console.WriteLine(finalSql);
// Console.ForegroundColor = oldColor;
// if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
// {
// Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
// }
// Console.WriteLine();
//};
//db.Aop.OnError = (ex) =>
//{
// Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
//};
});
// // 设置超时时间
// db.Ado.CommandTimeOut = 30;
// db.Aop.OnLogExecuted = (sql, pars) =>
// {
// var oldColor = Console.ForegroundColor;
// Console.ForegroundColor = ConsoleColor.Green;
// var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
// Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
// if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
// {
// Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
// }
// else
// {
// Console.WriteLine(finalSql);
// Console.ForegroundColor = oldColor;
// Console.WriteLine();
// }
// };
// db.Aop.OnError = (ex) =>
// {
// Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
// };
//});
});
services.AddUnitOfWork<SqlSugarUnitOfWork>();
services.AddConfigurableOptions<ConnectionStringsOptions>();