internal static string GetSortDirectionString(System.Web.Helpers.SortDirection sortDir) { return((sortDir == System.Web.Helpers.SortDirection.Ascending) ? "ASC" : "DESC"); }
protected static IQueryable <T> SortGenericExpression <TProperty>(IQueryable <T> data, Expression body, ParameterExpression param, System.Web.Helpers.SortDirection sortDirection) { Debug.Assert(data != null); Debug.Assert(body != null); Debug.Assert(param != null); // The IQueryable<dynamic> data source is cast as an IQueryable<object> at runtime. We must cast // this to an IQueryable<TElement> so that the reflection done by the LINQ expressions will work. //IQueryable<T_> data2 = data.Cast<T_>(); Expression <Func <T, TProperty> > lambda = Expression.Lambda <Func <T, TProperty> >(body, param); if (sortDirection == System.Web.Helpers.SortDirection.Descending) { return(data.OrderByDescending(lambda)); } else { return(data.OrderBy(lambda)); } }