WebAPI 2.2 OData v3 Jagged Array空结果

时间:2016-07-07 08:31:52

标签: asp.net-web-api2 odata geojson

我试图实现一个从类中返回Data的简单WebAPI。正确接收所有数据,使用锯齿状的字符串数组。 这是代码:

public IHttpActionResult GetGetGeoData_Result()
    {
        var results = db.GetGeoData().ToList();

        List<GeoJsonResult> jsonResult = new List<GeoJsonResult>();

        results.ForEach(r => jsonResult.Add(new GeoJsonResult()
        {
            Type = "Feature",
            Geometry = new GeoJsonGeometry()
            {
                Type = r.geo_type,
                Coordinates = this.CalculateCoordinates(r.coordinates) // This result is empty => Jagged string array (string[][])
            },
            Properties = new GeoJsonProperties()
            {
                Name = "SomeName"
            }
        }));

        return Ok(jsonResult);
    }

这是输出:

{
"odata.metadata": "http://localhost:65372/odata/$metadata#GetGeoData_Result",
"value": [
  {
      "Type": "Feature",
      "Geometry": {
          "Type": "Polygon",
          "Coordinates": [
            {},
            {},
            {},
            {},     
            {},
            {}
          ]
      },
      "Properties": {
          "Name": "SomeName"
      }

}] }

我做错了什么?

0 个答案:

没有答案