public async Task BasicPageAsync() { double totalCharge = 0; OffsetByPageNumberSpecification <Person> specification = new(1, 25); IPageQueryResult <Person> page = await _repository.QueryAsync(specification); while (page.HasNextPage is not null && page.HasNextPage.Value) { foreach (Person person in page.Items) { Console.WriteLine(person); } totalCharge += page.Charge; specification.NextPage(); page = await _repository.QueryAsync(specification); Console.WriteLine($"Get page {page.PageNumber} 25 results cost {page.Charge}"); } Console.WriteLine($"Total Charge {totalCharge} RU's"); }
public async Task FullPageNumberSpecificationAsync(int age) { double totalCharge = 0; UsersOrderByAgeOffsetSpecification specification = new(age); IPageQueryResult <Person> page = await _repository.QueryAsync(specification); while (page.HasNextPage is not null && page.HasNextPage.Value) { foreach (Person person in page.Items) { Console.WriteLine(person); } totalCharge += page.Charge; Console.WriteLine($"First 10 results cost {page.Charge}"); specification.NextPage(); page = await _repository.QueryAsync(specification); } Console.WriteLine($"Last results cost {page.Charge}"); Console.WriteLine($"Total Charge {totalCharge} RU's"); }