http://blog.csdn.net/q107770540/article/details/6133484
private static object GetPropertyValue(object obj, string property)
{
System.Reflection.PropertyInfo propertyInfo = obj.GetType().GetProperty(property);
//Console.WriteLine(propertyInfo.GetValue(obj, null));
return propertyInfo.GetValue(obj, null);
}
调用:
var query = from p in pets orderby GetPropertyValue(p, "Name") select p; //绿色为要排序的列名