我正在使用微风.js webapi 来公开下面的类。我知道不支持 DbGeography 类型,所以我使用 JsonIgnore 从输出中删除它,但是如何让它从元数据中被忽略/省略?
Public Class Household
<Key>
Public Property Id As Integer
Public Property Postcode As String
Public Property Saving As Decimal
<JsonIgnore>
Public Property Coordinates As DbGeography
Public ReadOnly Property Latitude As Double
Get
Return Coordinates.Latitude.Value
End Get
End Property
Public ReadOnly Property Longitude As Double
Get
Return Coordinates.Longitude.Value
End Get
End Property
End Class
<BreezeController>
Public Class HouseholdsController
Inherits ApiController
Private ReadOnly _contextProviders As EFContextProvider(Of EnergyFriendContext) = New EFContextProvider(Of EnergyFriendContext)
' ~/api/Households/Metadata
<HttpGet>
Public Function Metadata() As String
Return _contextProviders.Metadata()
End Function
' ~/api/Households/Households
' ~/api/Households/Households?$filter=IsArchived eq false&$orderby=CreatedAt
<HttpGet>
Public Function Households() As IQueryable(Of Household)
Return _contextProviders.Context.Households
End Function
End Class
微风js错误:
Unable to recognize DataType for: Edm.Geography