public override async Task GetCitiesStream( CitiesStreamRequest request, IServerStreamWriter <CityReply> responseStream, ServerCallContext context) { var getCitiesInfoPagination = await _cityManager.GetCitiesInfoPagination(request.NumberOfCities, request.PageNumber); var cities = _mapper.Map <List <CityReply> >(getCitiesInfoPagination.CityInfos.ToList()); foreach (var city in cities) { await responseStream.WriteAsync(city); } }
public async IAsyncEnumerable <CityReply> GetCitiesStream(int pageNumber = 1, int numberOfCities = 25) { var request = new CitiesStreamRequest() { PageNumber = pageNumber, NumberOfCities = numberOfCities }; using var call = _client.GetCitiesStream(request); await foreach (var cityReply in call.ResponseStream.ReadAllAsync()) { yield return(cityReply); } }