From 0a9c685511ca3ecc5f65eea399074c59612b35dd Mon Sep 17 00:00:00 2001 From: 28810 <2881099@qq.com> Date: Wed, 9 Jul 2025 15:26:29 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96=20pgsql=20+=20JsonMap=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=98=A0=E5=B0=84=E4=B8=BA=20jsonb=EF=BC=9B#?= =?UTF-8?q?2060?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Examples/base_entity/Program.cs | 2 +- .../FreeSql.Extensions.JsonMap/JsonMapCore.cs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Examples/base_entity/Program.cs b/Examples/base_entity/Program.cs index 55f0062de..b1215e50e 100644 --- a/Examples/base_entity/Program.cs +++ b/Examples/base_entity/Program.cs @@ -3498,7 +3498,7 @@ class Table11 { public int Id { get; set; } - [JsonMap, Column(DbType = "json")] + [JsonMap] public TableOptions Options { get; set; } } class TableOptions diff --git a/Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs b/Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs index 8bd1ed644..3e1565cde 100644 --- a/Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs +++ b/Extensions/FreeSql.Extensions.JsonMap/JsonMapCore.cs @@ -2,6 +2,7 @@ using FreeSql.DataAnnotations; using FreeSql.Internal.CommonProvider; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -62,8 +63,16 @@ public static class FreeSqlJsonMapCoreExtensions if (e.ModifyResult.MapType == null) { - e.ModifyResult.MapType = typeof(string); - e.ModifyResult.StringLength = -2; + switch (fsql.Ado.DataType) + { + case DataType.PostgreSQL: + e.ModifyResult.MapType = typeof(JObject); + break; + default: + e.ModifyResult.MapType = typeof(string); + e.ModifyResult.StringLength = -2; + break; + } } if (_dicTypes.TryAdd(e.Property.PropertyType, true)) {