Ejemplo n.º 1
0
        /// <summary>
        ///     获取Person的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <PersonListDto> > GetPagedPersons(GetPersonsInput input)
        {
            var sw = new Stopwatch();

            sw.Start();

            var query = _personRepository.GetAll().Include(a => a.PhoneNumbers).WhereIf(!input.Filter.IsNullOrWhiteSpace(),
                                                                                        a => a.Name.Contains(input.Filter) || a.Address.Contains(input.Filter) ||
                                                                                        a.EmailAddress.Contains(input.Filter));
            //TODO:根据传入的参数添加过滤条件
            var personCount = await query.CountAsync();

            var persons = await query
                          .OrderBy(input.Sorting).AsNoTracking()
                          .PageBy(input)
                          .ToListAsync();

            var personListDtos = ObjectMapper.Map <List <PersonListDto> >(persons);

            //var personListDtos = persons.MapTo<List<PersonListDto>>();

            sw.Stop();
            Logger.Error("耗时:" + sw.ElapsedMilliseconds + (sw.ElapsedMilliseconds > 1000 ? "#####" : string.Empty) + "毫秒\n"); // 可以记录操作

            return(new PagedResultDto <PersonListDto>(
                       personCount,
                       personListDtos
                       ));
        }
Ejemplo n.º 2
0
 public GetCitiesOutput GetList(GetPersonsInput input)
 {
     if (input.Name != null)
     {
         var lsit = _personRepository.GetAllList(o => o.Name == input.Name);
         return(new GetCitiesOutput
         {
             Persons = lsit.MapTo <List <PersonDto> >()
         });
     }
     else
     {
         return(new GetCitiesOutput());
     }
 }
Ejemplo n.º 3
0
        public GetPersonsOutput GetPersons(GetPersonsInput input)
        {
            Logger.Info("Getting Persons for input:" + input);

            var persons = _personRepository.GetAll();

            if (!string.IsNullOrEmpty(input.Name))
            {
                persons = persons.Where(p => p.Name == input.Name);
            }

            return(new GetPersonsOutput
            {
                Persons = Mapper.Map <List <PersonDto> >(persons)
            });
        }
Ejemplo n.º 4
0
        public async Task <PagedResultDto <PersonListDto> > GetPaged(GetPersonsInput input)
        {
            var query = _entityRepository.GetAll();
            // TODO:根据传入的参数添加过滤条件


            var count = await query.CountAsync();

            var entityList = await query
                             .OrderBy(input.Sorting).AsNoTracking()
                             .PageBy(input)
                             .ToListAsync();

            // var entityListDtos = ObjectMapper.Map<List<PersonListDto>>(entityList);
            var entityListDtos = entityList.MapTo <List <PersonListDto> >();

            return(new PagedResultDto <PersonListDto>(count, entityListDtos));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 获取Person的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <PersonListDto> > GetPagedPersons(GetPersonsInput input)
        {
            var query = _personRepository.GetAll();
            //TODO:根据传入的参数添加过滤条件
            var personCount = await query.CountAsync();

            var persons = await query
                          .OrderBy(input.Sorting)
                          .PageBy(input)
                          .ToListAsync();

            //var personListDtos = ObjectMapper.Map<List <PersonListDto>>(persons);
            var personListDtos = persons.MapTo <List <PersonListDto> >();

            return(new PagedResultDto <PersonListDto>(
                       personCount,
                       personListDtos
                       ));
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     获取Person的分页列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <PagedResultDto <PersonListDto> > GetPagedPersons(GetPersonsInput input)
        {
            var query = _personRepository.GetAll().Include(a => a.PhoneNumbers).WhereIf(!input.Filter.IsNullOrWhiteSpace(),
                                                                                        a => a.Name.Contains(input.Filter) || a.Address.Contains(input.Filter) ||
                                                                                        a.EmailAddress.Contains(input.Filter));
            //TODO:根据传入的参数添加过滤条件
            var personCount = await query.CountAsync();

            var persons = await query
                          .OrderBy(input.Sorting).AsNoTracking()
                          .PageBy(input)
                          .ToListAsync();

            //var personListDtos = ObjectMapper.Map<List <PersonListDto>>(persons);
            var personListDtos = persons.MapTo <List <PersonListDto> >();

            return(new PagedResultDto <PersonListDto>(
                       personCount,
                       personListDtos
                       ));
        }