예제 #1
0
        /// <summary>
        /// 分页查询方法
        /// </summary>
        /// <param name="samplePageInDto">分页查询实体</param>
        /// <returns>分页查询结果</returns>
        public PageOutDtoBase <SampleOutDto> GetSamplesByPage(SamplePageInDto samplePageInDto)
        {
            var result = new PageOutDtoBase <SampleOutDto>();
            Expression <Func <Sample, bool> > predicate =
                d => d.Name.Contains(samplePageInDto.Name.IsNullOrEmpty() ? "" : samplePageInDto.Name) || d.Remark.Contains(samplePageInDto.Remark.IsNullOrEmpty() ? "" : samplePageInDto.Remark);
            var list = _repository.GetPaged(predicate, samplePageInDto.CurrentPageIndex, samplePageInDto.PageSize,
                                            samplePageInDto.SortField, samplePageInDto.SortBy);

            result.Data  = Mapper.Map <List <SampleOutDto> >(list);
            result.Total = _repository.Count(predicate);
            return(result);
        }