how to store GeoJson?

时间:2018-06-04 17:29:57

标签: c# mongodb asp.net-web-api geojson

How should I go about storing GeoJson using C# MongoDB driver that is coming to Web API endpoint? Preferably I would like to do something like this:

Model:

        class House 
        {
           ...
           public GeoJsonPoint<GeoJson2DGeographicCoordinates> Location { get; set; }
        }

Endpoint:

    class HouseController 
    {
          [HttpPut]
          SaveHouse([FromBody] House house) 
          {
               db.GetCollection<House>("houses").UpdateOne(house);
          }

    }

problem is that the property Location is null in FromBody parameter. Newtonsoft Json.net is used for Json deserialization. The GeoJson coming from client should be valid, since it is coming straight from Mapbox draw functionality. There may be syntax errors in code. it is simplified, made up example.

0 个答案:

没有答案