日期:2014-05-20 浏览次数:21026 次
var queryGroup = query.ToList().GroupBy(q => q.GetType().GetProperty(columnName).GetValue(q, null));
------解决方案--------------------
private static object GetPropertyValue(object obj, string property)
{
System.Reflection.PropertyInfo propertyInfo=obj.GetType().GetProperty(property);
return propertyInfo.GetValue(obj, null);
}
string columnName = "AppearanceDirector";
var queryGroup = query.GroupBy(q =>GetPropertyValue(q,columnName));
http://blog.csdn.net/q107770540/archive/2011/01/13/6133484.aspx