Entity framework core 从实体获取Geojson字符串很热吗?

Entity framework core 从实体获取Geojson字符串很热吗?,entity-framework-core,geospatial,npgsql,nettopologysuite,Entity Framework Core,Geospatial,Npgsql,Nettopologysuite,我的实体框架实体城市类型具有几何体属性。我得到的数据如下: public class City { public int Id { get; set; } public string Name { get; set; } public Geometry Location { get; set; } } 公共类CitiesController{ 公共任务Get(){ var nearbyCities=context.Cities 其中(c=>c.位置.距离(某点)

我的实体框架实体
城市
类型具有
几何体
属性。我得到的数据如下:

public class City
{
    public int Id { get; set; }
    public string Name { get; set; }
    public Geometry Location { get; set; }
}
公共类CitiesController{
公共任务Get(){
var nearbyCities=context.Cities
其中(c=>c.位置.距离(某点)<100);
响应正常(?geojson字符串??);
}
}

因此,我想知道如何使用Npgsql或Nettopologysuite获取Geojson字符串?

您可能需要使用:将从数据库获取的Nettopologysuite对象传递给GeoJsonSerializer

public class CitiesController {

   public Task<IActionResult> Get(){
       var nearbyCities = context.Cities
                  .Where(c => c.Location.Distance(somePoint) < 100);

       response OK(??? geojson string ???);
   }
}