public async Task <ListResultDto <BookListListDto> > GetAll(GetBookListsInput input) { var query = _entityRepository.GetAll().AsNoTracking() .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), o => o.Name.Contains(input.FilterText)); var count = await query.CountAsync(); var entityList = await query .OrderBy(input.Sorting) //.PageBy(input) .ToListAsync(); return(new ListResultDto <BookListListDto>() { Items = entityList.MapTo <IReadOnlyList <BookListListDto> >() }); }
public async Task <PagedResultDto <BookListListDto> > GetPaged(GetBookListsInput input) { var query = _entityRepository.GetAll().AsNoTracking() .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), o => o.Name.Contains(input.FilterText)); // TODO:根据传入的参数添加过滤条件 var count = await query.CountAsync(); var entityList = await query .OrderBy(input.Sorting) .PageBy(input) .ToListAsync(); // var entityListDtos = ObjectMapper.Map<List<BookListListDto>>(entityList); var entityListDtos = entityList.MapTo <List <BookListListDto> >(); return(new PagedResultDto <BookListListDto>(count, entityListDtos)); }
public async Task <PagedResultDto <BookListListDto> > GetPaged(GetBookListsInput input) { var query = _bookListRepository.GetAll() //模糊搜索书单名称 .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.ListName.Contains(input.FilterText)) //模糊搜索简介 .WhereIf(!input.FilterText.IsNullOrWhiteSpace(), a => a.Intro.Contains(input.FilterText)) ; // TODO:根据传入的参数添加过滤条件 var count = await query.CountAsync(); var bookListList = await query .OrderBy(input.Sorting).AsNoTracking() .PageBy(input) .ToListAsync(); var bookListListDtos = ObjectMapper.Map <List <BookListListDto> >(bookListList); return(new PagedResultDto <BookListListDto>(count, bookListListDtos)); }