'Web Api adding underscore prefix to json property names
This is what I get
{"_ProviderId":476,"_FirstName":" ","_LastName":"Nam Of Provders","_Specialty":"Pediatrics"}
api code
Public Class ProviderSimpleModel
Public Property ProviderId As Integer
Public Property FirstName As String
Public Property LastName As String
Public Property Specialty As String
Public ReadOnly Property Name() As String
Get
Return If(FirstName, "").Trim() + " " + If(LastName, "").Trim()
End Get
End Property
End Class
<HttpGet>
Public Function GetProviderSimpleList(Optional id As Integer = 0) As List(Of ProviderSimpleModel)
Dim db As New LinqConsole.MyDataContext
Dim q = From pr In db.Providers
Where pr.ProviderId = id OrElse id = 0
Select New ProviderSimpleModel With
{
.ProviderId = pr.ProviderId,
.FirstName = pr.FirstName,
.LastName = pr.LastName,
.Specialty = pr.Specialty
}
Dim list = q.OrderBy(Function(x) x.FirstName).ThenBy(Function(x) x.LastName).ToList()
db.Dispose()
Return list
End Function
why is this happening and how to stop it?
Solution 1:[1]
Updated Newtonsoft from 10.x to 13.x, issue solved.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | boruchsiper |
