From 0d64e56562fa6704c11be811749881ea68ae29be Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 20 Jun 2023 18:05:45 +0800 Subject: [PATCH] Synchronization code --- Src/Asp.NetCore2/SqlSugar/Infrastructure/StaticConfig.cs | 2 ++ .../Realization/PostgreSQL/PostgreSQLProvider.cs | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Infrastructure/StaticConfig.cs b/Src/Asp.NetCore2/SqlSugar/Infrastructure/StaticConfig.cs index 170e88a45..42d698877 100644 --- a/Src/Asp.NetCore2/SqlSugar/Infrastructure/StaticConfig.cs +++ b/Src/Asp.NetCore2/SqlSugar/Infrastructure/StaticConfig.cs @@ -9,6 +9,8 @@ namespace SqlSugar { public static Func Encode { get; set; } public static Func Decode{ get; set; } + public static bool AppContext_ConvertInfinityDateTime { get; set; } + public const string CodeFirst_BigString = "varcharmax,longtext,text,clob"; public static Func CustomSnowFlakeFunc; diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs b/Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs index 2a4dd87ae..764443673 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/PostgreSQL/PostgreSQLProvider.cs @@ -14,9 +14,12 @@ namespace SqlSugar { public PostgreSQLProvider() { - - AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); - AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + + if (StaticConfig.AppContext_ConvertInfinityDateTime == false) + { + AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); + AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true); + } } public override IDbConnection Connection