Accepted answer

Use Dynamic LINQ (, section Downloading the LINQ Dynamic Query Library) and specify the field to sort by as a string:

data = _repository.FindAll().OrderBy(formData["sidx"].ToString()).ToList();


That should work provided formData["sidx"] specifies the name of an existing property with the proper case. Check what formData["sidx"] is returning and if it's in the correct case. I would start with hard-coding a real property name. If that works check formData["sidx"].

For example, given a class with a property of Name your code would throw a NullReferenceException if you used GetProperty("NaMe").

Related Query

More Query from same tag