public async Task <PopularResult <byte[]> > GetBytesAsync(DictTypeQueryDto dto) { var result = new PopularResult <byte[]>(); var queryAble = _dictTypeRepository .WhereIf(!dto.Name.IsNullOrWhiteSpace(), dictType => dictType.Name.Contains(dto.Name)); var dictTypes = await AsyncExecuter.ToListAsync(queryAble); //转换为导出对象 var dtos = ObjectMapper.Map <List <DictTypeEntity>, List <DictTypeDto> >(dictTypes); var stream = EPPlusHelper.GetMemoryStream(dtos); result.Success(stream.ToArray()); return(result); }
public async Task <PopularResult <PagedResultDto <DictTypeDto> > > GetListAsync(DictTypeQueryDto dto) { var result = new PopularResult <PagedResultDto <DictTypeDto> >(); var queryable = _dictTypeRepository .WhereIf(!dto.Name.IsNullOrWhiteSpace(), dictType => dictType.Name.Contains(dto.Name)); var dictTypes = await _dictTypeRepository.GetPagedAsync(dto.Name, dto.SkipCount, dto.MaxResultCount); var totalCount = await AsyncExecuter.CountAsync(queryable); var dtos = ObjectMapper.Map <List <DictTypeEntity>, List <DictTypeDto> >(dictTypes); result.Success(new PagedResultDto <DictTypeDto>(totalCount, dtos)); return(result); }