//获取类【OflSchApplyVM】的所有属性
PropertyInfo[] _PropertyInfo = typeof(OflSchApplyVM).GetProperties();
//对应属性
PropertyInfo _pro = null;
//获取属性名=【sort】的属性
foreach (var item in _PropertyInfo)
{
if (item.Name == sort)
{
_pro = item;
}
}
//List<T>排序
if (_pro != null)
{
if (order == "desc")
{
lstPage = lstPage.OrderByDescending(a => _pro).ToList();
}
if (order == "asc")
{
lstPage = lstPage.OrderBy(a => _pro).ToList();
}
}