示例#1
0
        private static IQueryable <T> ApplySort <T>(this IQueryable <T> query, Sorts <T> sorts)
        {
            if (!sorts.IsValid())
            {
                return(query);
            }
            dynamic sort    = sorts.Get();
            var     results = Sorts <T> .ApplySort(query, sort);

            return(results);
        }
示例#2
0
        internal IQueryable <T> ApplySort <TKey>(IQueryable <T> query, Sorts <T> sorts, Sort <T, TKey> sort)
        {
            IOrderedQueryable <T> nonFirstQuerable = null;
            var first = true;

            foreach (var c in Power())
            {
                if (first)
                {
                    nonFirstQuerable = ApplySortFisrt(query, c);
                    first            = false;
                }
                else
                {
                    nonFirstQuerable = ApplySortNonFisrt(nonFirstQuerable, c);
                }
            }

            return(nonFirstQuerable);
        }
示例#3
0
        /// <summary>
        /// Paginates your query and returns Page object for the given page number and page size.
        /// </summary>
        /// <typeparam name="T">Type of Entity for which pagination is being implemented.</typeparam>
        /// <param name="query">IQueryable on which pagination will be applied.</param>
        /// <param name="pageNumber">The page no. which needs to be fetched.</param>
        /// <param name="pageSize">The number or records expected in the page.</param>
        /// <param name="sorts">Conditional sorts.</param>
        /// <param name="filters">Conditional filters.</param>
        /// <returns>A Page object with filtered data for the given page number and page size.</returns>
        public static async Task <Page <T> > PaginateAsync <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts, Filters <T> filters)
        {
            var results = query.ApplyFilter(filters);

            return(await results.PaginateAsync(pageNumber, pageSize, sorts));
        }
示例#4
0
        /// <summary>
        /// See `Task<Page<T>> PaginateAsync<T>(this IQueryable<T> query, int pageNumber, int pageSize, Sorts<T> sorts, Filters<T> filters)`
        /// </summary>
        public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts, Filters <T> filters)
        {
            var results = query.ApplyFilter(filters);

            return(results.Paginate(pageNumber, pageSize, sorts));
        }
示例#5
0
        /// <summary>
        /// Paginates your query and returns Page object for the given page number and page size.
        /// </summary>
        /// <typeparam name="T">Type of Entity for which pagination is being implemented.</typeparam>
        /// <param name="query">IQueryable on which pagination will be applied.</param>
        /// <param name="pageNumber">The page no. which needs to be fetched.</param>
        /// <param name="pageSize">The number or records expected in the page.</param>
        /// <param name="sorts">Conditional sorts.</param>
        /// <returns>A Page object with filtered data for the given page number and page size.</returns>
        public static async Task <Page <T> > PaginateAsync <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts)
        {
            var result = query.ApplySort(sorts);

            return(await result.PaginateAsync(pageNumber, pageSize));
        }
示例#6
0
        /// <summary>
        /// See `Task<Page<T>> PaginateAsync<T>(this IQueryable<T> query, int pageNumber, int pageSize, Sorts<T> sorts)`
        /// </summary>
        public static Page <T> Paginate <T>(this IQueryable <T> query, int pageNumber, int pageSize, Sorts <T> sorts)
        {
            var result = query.ApplySort(sorts);

            return(result.Paginate(pageNumber, pageSize));
        }