예제 #1
0
        /// <summary>
        /// Returns the paged and ordered list
        /// </summary>
        /// <typeparam name="EntityType">Entity type</typeparam>
        /// <param name="source">Entity Framework collection</param>
        /// <param name="filter">Sorting and Paging Information</param>
        /// <returns>A collection containing page records</returns>
        public static PagedList <EntityType> ToPaged <EntityType>(this IQueryable <EntityType> source, EntityFilter <EntityType> filter)
            where EntityType : class
        {
            var sorted = ToOrdered(source, filter);

            var result = ToPaged(sorted, filter.PageNumber, filter.PageSize);

            return(result);
        }
예제 #2
0
        /// <summary>
        /// Returns the ordered list
        /// </summary>
        /// <typeparam name="EntityType">Entity Type</typeparam>
        /// <param name="source">Entity Framework collection</param>
        /// <param name="filter">Sort information</param>
        /// <returns>A collection containing the page records</returns>
        public static IOrderedQueryable <EntityType> ToOrdered <EntityType>(this IQueryable <EntityType> source, EntityFilter <EntityType> filter)
            where EntityType : class
        {
            IOrderedQueryable <EntityType> sorted = null;

            if (filter.SortExpression != null)
            {
                sorted = Sort <EntityType>(source, filter.SortDescending, filter.SortExpression);
            }
            else
            {
                sorted = source.OrderBy(i => 1);
            }

            return(sorted);
        }