GeoJSON4EntityFramework
GeoJSON4EntityFramework copied to clipboard
JsonConverter attribute usage
It would be useful if this project included a JSON.NET JsonConverter at the top level that could just be used with a [JsonConverter()] attribute: https://www.newtonsoft.com/json/help/html/JsonConverterAttributeClass.htm
Ideally, I should be able to just adjust my EF model or DTO to my EF model, and wherever JSON serialization happens (such as automatically by WebAPI) it will convert to GeoJSON:
[JsonConverter(typeof(DbGeometryGeoJsonConverter))]
public DbGeometry Geometry { get; set; }
I don't see an example like this in the documentation and searching the source code there doesn't appear to be a class that can be directly used as a JsonConverter in this way. Let me know if I just missed it.
@WorldMaker The code uses a similar method, but it constructs the geometry as a composite structure first, then serialize it to a json. DbGeometry consists of defined well-known features but geojson has a hierarchical structure.
But, it seems quite doable in the way that you mentioned. But there may be some changes needed in the usage. I'll take in the consideration for v3 implementation.