예제 #1
0
        public virtual Task <List <T> > ListAsync(
            Expression <Func <T, bool> > predicate,
            SortOptions sortOptions = null,
            int?pageSize            = int.MaxValue,
            int?pageNumber          = 1)
        {
            if (sortOptions == null)
            {
                sortOptions = SortOptions.GetDefaultValue();
            }
            if (!pageSize.HasValue)
            {
                pageSize = int.MaxValue;
            }
            if (!pageNumber.HasValue)
            {
                pageNumber = 1;
            }

            return(_dbContext.Set <T>()
                   .Where(predicate)
                   .OrderBy(sortOptions.Column + " " + (sortOptions.Order == SortOrder.Ascending ? "ASC" : "DESC"))
                   .Skip((pageNumber.Value - 1) * pageSize.Value)
                   .Take(pageSize.Value)
                   .ToListAsync());
        }
예제 #2
0
        public override async Task <List <Charge> > ListAsync(
            Expression <Func <Charge, bool> > predicate,
            SortOptions sortOptions = null,
            int?pageSize            = int.MaxValue, int?pageNumber = 1)
        {
            if (sortOptions == null)
            {
                sortOptions = SortOptions.GetDefaultValue();
            }
            if (!pageSize.HasValue)
            {
                pageSize = int.MaxValue;
            }
            if (!pageNumber.HasValue)
            {
                pageNumber = 1;
            }

            if (pageSize <= 0)
            {
                throw new ArgumentException("Page size must be greater than zero");
            }

            return(await _dbContext.Charges
                   .Include(x => x.Payments).ThenInclude(x => x.Payment)
                   .Include(x => x.Event).ThenInclude(x => x.User)
                   .Include(x => x.Event).ThenInclude(x => x.Type).ThenInclude(x => x.Category)
                   .Where(predicate)
                   .OrderBy(sortOptions.Column + " " + (sortOptions.Order == SortOrder.Ascending ? "ASC" : "DESC"))
                   .Skip((pageNumber.Value - 1) * pageSize.Value)
                   .Take(pageSize.Value)
                   .ToListAsync());
        }
예제 #3
0
        public virtual Task <List <T> > ListAsync(SortOptions sortOptions = null, int?pageSize = int.MaxValue, int?pageNumber = 1)
        {
            if (sortOptions == null)
            {
                sortOptions = SortOptions.GetDefaultValue();
            }
            if (!pageSize.HasValue)
            {
                pageSize = int.MaxValue;
            }
            if (!pageNumber.HasValue)
            {
                pageNumber = 1;
            }

            if (pageSize <= 0)
            {
                throw new ArgumentException("Page size must be greater than zero");
            }

            return(_dbContext.Set <T>()
                   .OrderBy(sortOptions.Column + " " + (sortOptions.Order == SortOrder.Ascending ? "ASC" : "DESC"))
                   .Skip((pageNumber.Value - 1) * pageSize.Value)
                   .Take(pageSize.Value)
                   .ToListAsync());
        }