28,391
社区成员
发帖
与我相关
我的任务
分享
public List<QueryResult> QueryBooks(string orderKey)
{
BooksDB context = new BooksDB("name=BooksDB");
List<QueryResult> results = new List<QueryResult>();
using (context)
{
results = (from result in context.QueryResults
select result).OrderBy(t =>GetPropertyValue(t,orderKey)).ToList();
}
return results;
}
private static object GetPropertyValue(object obj, string property)
{
System.Reflection.PropertyInfo propertyInfo=obj.GetType().GetProperty(property);
return propertyInfo.GetValue(obj, null);
}