I have dynamic linq query with OrderBy.
.AsQueryable().OrderBy("FullName", asc)
After sorting by FullName, I need to sort by status (something like ThenBy()). Status may have vales e.g. "A", "B", "C", "D" But I need to sort in following sequence "B", "A", "D", "C". As result can't use asc/desc in this case.
You need to do the following:
a) Define the collection of your keys in the order you want
var keys = new string[]{"B", "A", "D", "C"};
b) Use the above keys to define the custom order of your data
var result = yourCollection.AsQueryable()
.OrderBy("FullName", asc)
.ThenBy(x=>keys.IndexOf(x.Status));