public async Task <PaginatedList <ExpenseCategory> > GetAllAsync(int residentialId, Parameter parameter) { var columnsToFilter = ColumnFilter.GetNames <ExpenseCategoryEf>(x => x.Name, x => x.Description); var query = _repository.AsNoTracking() .Where(x => x.ResidentialId == residentialId) .Contains(parameter.Filter, columnsToFilter).ApplySort(parameter.SortBy, parameter.IsSortDesc); var totalOfItems = await query.CountAsync(); var entities = await query.Take(parameter.Page, parameter.ItemsPerPage).ToListAsync(); var models = _mapper.Map <IEnumerable <ExpenseCategory> >(entities); return(new PaginatedList <ExpenseCategory>(models, totalOfItems)); }