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)) {