Grouplist is the raw data set,list<t>
SortOrder is the sort type, desc or ASC
Sortname is the Sort property name
1. Use reflection.
Private Static ObjectGetPropertyValue (ObjectObjstringProperty ) {System.Reflection.PropertyInfo PropertyInfo=obj. GetType (). GetProperty (property); returnPropertyinfo.getvalue (obj,NULL);} varResultlist = SortOrder = ="desc"? Grouplist.orderbydescending (p = getpropertyvalue (P, sortname)): Grouplist.orderby (p =GetPropertyValue (P, sortname));//LINQ mode://varResultList1 = fromPinchGrouplist byGetPropertyValue (p, M.sortname)Selectp;if(SortOrder = ="desc") ResultList1= fromPinchGrouplist byGetPropertyValue (p, Sortname)Descending SelectP
2. Call AsQueryable ()
Converts a generic system.collections.generic.ienumerable<t> to a generic system.linq.iqueryable<t>.
var groupquerylist = grouplist.asqueryable (); // Here var tmplist = groupquerylist. (Sortname, SortOrder);
Reference: http://stackoverflow.com/questions/41244/dynamic-linq-orderby-on-ienumerablet#41262
C # LINQ Query dynamic by