I have code similar to this in my controller which is working successfully, var results = from c in dbContext.MyClass orderby c.EnrtyDate descending select c; return View(results.ToList());
Now the user would like to select the field(s) to OrderBy. I have 5 dropdown lists each of which contains the same 5 field name choices. The user can select the first field to order by from the first dropdown list, then the second from the second dropdown list, etc. up to a total of five fields; let's call the value of the first selection sort1, the second sort2, then sort3, sort4, and sort5.
I need to make the orderby reflect the choices the user has made, e.g., orderby sort1, sort2, sort3, sort4, sort5 How do I reference this fields in the orderby since they are variables containing the field names, not the actual field names themselves? I cannot code for all of the hundreds of possible combinations individually.