mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 18:22:11 +08:00
修复.NET bool类型转换为pgSql int2
This commit is contained in:
@@ -184,8 +184,28 @@ namespace OpenAuth.WebApi
|
||||
{
|
||||
DbType = dbType.Value,
|
||||
ConnectionString = connectionString,
|
||||
IsAutoCloseConnection = true
|
||||
IsAutoCloseConnection = true
|
||||
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
||||
|
||||
if(dbType.Value != SqlSugar.DbType.PostgreSQL){
|
||||
return sqlSugar;
|
||||
}
|
||||
|
||||
// 配置bool类型转换为smallint
|
||||
sqlSugar.Aop.OnExecutingChangeSql = (sql, parameters) =>
|
||||
{
|
||||
foreach (var param in parameters)
|
||||
{
|
||||
if (param.Value is bool boolValue)
|
||||
{
|
||||
param.DbType = System.Data.DbType.Int16;
|
||||
// 将 bool 转换为 smallint
|
||||
param.Value = boolValue ? (short)1 : (short)0;
|
||||
}
|
||||
}
|
||||
// 返回修改后的 SQL 和参数
|
||||
return new System.Collections.Generic.KeyValuePair<string, SugarParameter[]>(sql, parameters);
|
||||
};
|
||||
return sqlSugar;
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user