I have the following JSON and I'm wondering if it's possible to do a multiple OrderBy
using Linq.
var body = @"[{
""portOfLoading"": ""GOT"",
""bookingResponses"":[{
""bookingNumber"": ""11"",
""comment"": ""LOFO"",
""customerReference"": ""3423462"",
""departureDate"": ""2017-04-10"",
""departureTime"": ""18:00"",
""description"": ""desc"",
""length"": ""7482"",
""netWeight"": ""12345"",
""plugin"": ""true"",
""resourceCode"": ""CONT26"",
""route"": ""GOTZEE"",
""status"": ""Price missing"",
""unitNumber"": ""ABC123"",
""width"": ""0""
}
]
}
,
{
""portOfLoading"": ""GOT"",
""bookingResponses"":[{
""bookingNumber"": ""3"",
""comment"": ""LOFO"",
""customerReference"": ""3423462"",
""departureDate"": ""2017-04-10"",
""departureTime"": ""18:00"",
""description"": ""desc"",
""length"": ""7482"",
""netWeight"": ""12345"",
""plugin"": ""true"",
""resourceCode"": ""CONT26"",
""route"": ""GOTZEE"",
""status"": ""Price missing"",
""unitNumber"": ""ABC123"",
""width"": ""0""
}
]
}
,{
""portOfLoading"": ""OUL"",
""bookingResponses"":[{
""bookingNumber"": ""7"",
""comment"": ""STANDBY"",
""customerReference"": ""3423462"",
""departureDate"": ""2017-04-10"",
""departureTime"": ""18:00"",
""description"": ""desc"",
""length"": ""7482"",
""netWeight"": ""12345"",
""plugin"": ""true"",
""resourceCode"": ""CONT26"",
""route"": ""OULZEE"",
""status"": ""Price missing"",
""unitNumber"": ""ABC123"",
""width"": ""0""
}
]
},{
""portOfLoading"": ""ZEE"",
""bookingResponses"":[{
""bookingNumber"": ""3"",
""comment"": ""STANDBY"",
""customerReference"": ""3423462"",
""departureDate"": ""2017-04-10"",
""departureTime"": ""18:00"",
""description"": ""desc"",
""length"": ""7482"",
""netWeight"": ""12345"",
""plugin"": ""true"",
""resourceCode"": ""CONT26"",
""route"": ""ZEEGOT"",
""status"": ""Price missing"",
""unitNumber"": ""ABC123"",
""width"": ""0""
}
]
},{
""portOfLoading"": ""GOT"",
""bookingResponses"":[{
""bookingNumber"": ""10"",
""comment"": ""STANDBY"",
""customerReference"": ""3423462"",
""departureDate"": ""2017-04-10"",
""departureTime"": ""18:00"",
""description"": ""desc"",
""length"": ""7482"",
""netWeight"": ""12345"",
""plugin"": ""true"",
""resourceCode"": ""CONT26"",
""route"": ""GOTZEE"",
""status"": ""Price missing"",
""unitNumber"": ""ABC123"",
""width"": ""0""
}
]
}
]";
So far I've got the 'first' orderby to work, like this:
JArray jsonVal = JArray.Parse(body);
JArray sortQuery = new JArray(jsonVal.OrderBy(obj => obj["portOfLoading"]));
After "portOfLoading"
I want to orderBy "bookingNumber"
. I've tried using ThenBy
and so on but never got it to work. Thanks