score:3

Accepted answer

Use Dynamic LINQ (http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx, 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();

score:0

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