public override Task <PersonListResponse> GetPersonList(GetPersonRequest request, ServerCallContext context) { return(Task.Factory.StartNew <PersonListResponse>(() => { TestEntity.BLL.Person bll = new TestEntity.BLL.Person(); var result = bll.GetPersonList(new TestEntity.Params.GetPersonParam()); var response = new PersonListResponse(); return response; })); }
public async Task <PersonListResponse> FindAllAsync() { var result = await _personService.FindAllAsync(); var response = new PersonListResponse(); response.Persons = new List <PersonDto>(); response.Persons.AddRange(result.Select(x => _mapper.Map <PersonDto>(x))); return(response); }
/* * 1,AutoMapping的使用实例 * 2,Task异步 */ public override Task <PersonListResponse> GetPersonList(GetPersonRequest request, ServerCallContext context) { return(Task.Factory.StartNew <PersonListResponse>(() => { var response = new PersonListResponse(); TestEntity.BLL.Person bll = new TestEntity.BLL.Person(); var result = bll.GetPersonList(Mapper.Map <GetPersonRequest, TestEntity.Params.GetPersonParam>(request)); response.Pager = Mapper.Map <TestEntity.Models.Pager <TestEntity.Models.Person>, PagerResponse>(result); response.List.AddRange(Mapper.Map <List <TestEntity.Models.Person>, List <Person> >(result.Items)); return response; })); }