我正在使用John Papa在最新的PluralSight课程中概述的方法,利用Angular、Breeze和Web API 2构建单页应用。一切运行良好,可以从服务器获取信息并对其进行更新、插入、删除等操作。然而,我使用了空间类型,当我尝试更新具有空间类型的实体时,会出现以下错误:
发生类型为 'Newtonsoft.Json.JsonSerializationException' 的异常, 但未在用户代码中处理。
附加信息:在'System.Data.Entity.Spatial.DbGeometry'上获取'WellKnownValue'的值时出错。
内部异常似乎指向WellKnownValue为空的事实,但实际情况并非如此。我已经检查了发送到服务器的JSON数据,然后通过Breeze ContextProvider保存,并使用SaveChanges方法。
{
"entities": [
{
"TableKey": 2,
"CaseName": "Mikhail Lermontov",
"StartDate": "2013-06-11T00:00:00Z",
"EndDate": null,
"IsCurrent": true,
"SRID": 109,
"Shape": {
"$id": "2",
"$type": "System.Data.Entity.Spatial.DbGeometry, EntityFramework",
"Geometry": {
"$id": "3",
"$type": "System.Data.Entity.Spatial.DbGeometryWellKnownValue, EntityFramework",
"CoordinateSystemId": 2193,
"WellKnownText": "POLYGON ((1695943 5462665, 1713098 5462665, 1713098 5449659, 1695943 5449659, 1695943 5462665))"
}
},
"SpillLocation": "Marlborough Sounds",
"Image": "http://www.nzmaritime.co.nz/images/lm5.jpg\r\n",
"DefaultBaseMapKey": 2,
"__unmapped": {
"isPartial": false
},
"entityAspect": {
"entityTypeName": "DatSpillCase:#Osiris.Model",
"defaultResourceName": "DatSpillCases",
"entityState": "Modified",
"originalValuesMap": {
"CaseName": "Mikhail Lermontov"
},
"autoGeneratedKey": {
"propertyName": "TableKey",
"autoGeneratedKeyType": "Identity"
}
}
}
],
"saveOptions": {}
}
所以我的问题是,是否可能在NewtonSoft库中反序列化DbGeometry类型,如果不行,有什么建议来解决这个问题。