pgsql Geometry 位置读取时候出错。 返回

SqlSugar 沟通中
1 396
该叫什么 斌斌 发布于2026/1/29
悬赏:0 飞吻

image.png

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 回复