Только для информации:
Я не могу использовать нумерацию страниц (пропустить, взять), поскольку записи поступают из нескольких таблиц.Подробно вы можете проверить модель Report
.
Я должен попытаться получить данные one by one
в пользовательском интерфейсе из WebAPI.
Приведенный ниже код извлекает все записи одновременноно записи огромны, и это занимает больше минуты, что плохо для UX.
Модель
public class Report
{
public string Region { get; set; }
public List<Country> CountryList { get; set; }
public List<State> StateList { get; set; }
public List<District> DistrictList { get; set; }
}
Web API
[HttpGet]
public HttpResponseMessage GetReports()
{
var tempReports = this.mService.GetReports();
if (tempReports == null)
{
return ErrorResult(HttpStatusCode.NotFound);
}
return OK(tempReports);
}
Сервис
public IEnumerable<Report> GetReports()
{
List<int> totalValidRecords = ; //This comes from a table on the basic of which the report will be generated.
foreach(int id in totalValidRecords)
{
List<Region> regions= //gets list of record from Region table.
foreach(Region region in regions)
{
List<Country> countries= //gets list of countries from country table based on region.
foreach(Country country in counties)
{
List<State> states = //gets list of states from State table based on country.
foreach(State state in states)
{
List<District> districts = //gets list of districts from District table based on state.
//Other logic which computes and access other rest of dependent tables data.
}
}
}
yield return report;
}
}