pgsql Geometry 位置读取时候出错。 返回
斌斌 发布于2026/1/29

Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'CoordinateValue' with type 'NetTopologySuite.Geometries.Coordinate'. Path 'Model[0].EvalLocation.CoordinateSequence.First'.\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property
热忱回答(1)
-
斌斌 VIP0
2026/1/29按下面这样倒是能解决
1. 添加了 GeoJSON 包:
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="4.0.0" />
2. 添加了 GeoJSON 转换器配置:
// 添加 NetTopologySuite GeoJSON 转换器,解决 Geometry 类型序列化循环引用问题
foreach (var converter in NetTopologySuite.IO.GeoJsonSerializer.Create(
new NetTopologySuite.Geometries.GeometryFactory()).Converters)
{
options.SerializerSettings.Converters.Add(converter);
}
0 回复