public async Task <PaginatedList <House> > GetAllAsync(int residentialId, Parameter parameter) { var query = _repository.AsNoTracking() .Include(x => x.HouseUsers) .ThenInclude(x => x.User) .Where(x => x.ResidentialId == residentialId) .Contains(parameter.Filter).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 <House> >(entities); return(new PaginatedList <House>(models, totalOfItems)); }