问题描述及重现代码:
之前是 MySQL 默认不设置 sql.UseJsonMap(); 也不会换行,PG 后怎么配置都会换行
Newtonsoft.Json.JsonConvert.DefaultSettings = () => new Newtonsoft.Json.JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.None, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore };
两种都试过,倒不是大问题
初始化
// c# code
sql = build.UseConnectionFactory(DataType.PostgreSQL, () => new NpgsqlConnection(com)).Build(); //请务必定义成 Singleton 单例模式
sql.UseJsonMap(new Newtonsoft.Json.JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.None, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore });
数据库工具中查看依旧是带格式化的

更新数据
var dCamera = new Dictionary<int, Model.h_deviceCamera>(3);
Db.sql.Update<SQL.r_device>().Where(a => a.id == id).Set(a => a.cameras, dCamera).Set(a => a.cameraNum, dCamera.Count).ExecuteAffrows();
表实体
[Description("设备")]
public class r_device
{
/// <summary>
/// PUID
/// </summary>
[Column(IsPrimary = true, StringLength = 32)]
[Description("PUID")]
public string id { get; set; }
/// <summary>
/// 状态
/// </summary>
[Description("状态")]
public bool state { get; set; }
/// <summary>
/// 名称
/// </summary>
[Column(StringLength = 64)]
[Description("名称")]
public string name { get; set; }
/// <summary>
/// 在线状态
/// </summary>
[Description("在线状态")]
public bool online { get; set; }
/// <summary>
/// 摄像头信息
/// </summary>
[JsonMap]
[Description("摄像头信息")]
[Column(DbType = "text")]
public Dictionary<int, Model.h_deviceCamera> cameras { get; set; }
/// <summary>
/// 摄像头数量
/// </summary>
[Description("摄像头数量")]
public int cameraNum { get; set; }
}
public class h_deviceCamera
{
/// <summary>
/// 摄像头名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 启用AI
/// </summary>
public int ai { get; set; }
/// <summary>
/// 拉流
/// </summary>
public int pull { get; set; }
}
期望:
数据库版本
3.5.311
安装的Nuget包
FreeSql.Provider.PostgreSQL
.net framework/. net core? 及具体版本
NET 10 10.0.303
问题描述及重现代码:
之前是 MySQL 默认不设置
sql.UseJsonMap();也不会换行,PG 后怎么配置都会换行两种都试过,倒不是大问题
初始化
数据库工具中查看依旧是带格式化的

更新数据
表实体
期望:
数据库版本
3.5.311
安装的Nuget包
FreeSql.Provider.PostgreSQL
.net framework/. net core? 及具体版本
NET 10
10.0.303