I am slowly getting a hang of JSON. At this point I am stuck with the issue of populating a datagrid in VB.NET from a JSON response. The JSON response is something like
{
"inventory": [
{
"ItemId": 123,
"category": "A",
"Description": "xyz",
"Code": "2",
"company": "Z",
"quantity": 5,
"price": 2.5,
}
]
}
The code I am using is
Public Class Inventory
Public Property ItemId As Integer
Public Property description As String
Public Property Code As String
Public Property category As String
Public Property company As String
Public Property quantity As Integer
Public Property Price As Integer
End Class
Dim parsedObject = JObject.Parse(response)
Dim docs = JArray.FromObject(parsedObject("inventory")).Select(Function(x) x.ToObject(Of MyClass.Inventory)())
Dim invenList = docs.Select(Function(x) x).OrderBy(Function(x) x.description).ToList
myGrid.DataSource = invenList
myGrid.DataBind()
I am able to populate a datagrid using the code above. Now I need to group by description, code, category and get Sum(Quantity) and Max(Price). How can I modify my LINQ query for that?