Func<T, TResult>的一个使用场合
string propertyName = GridViewSortExpression;
Func<Entity, object> orderbyField = entity=>entity.GetType().InvokeMember(propertyName, BindingFlags.GetProperty, null, entity, new object[] { });
GridView.DataSource = GridViewSortDirection == SortDirection.Ascending ? entities.OrderBy(orderbyField) : entities.OrderByDescending(orderbyField);
Func<Entity, object> orderbyField = entity=>entity.GetType().InvokeMember(propertyName, BindingFlags.GetProperty, null, entity, new object[] { });
GridView.DataSource = GridViewSortDirection == SortDirection.Ascending ? entities.OrderBy(orderbyField) : entities.OrderByDescending(orderbyField);