I am fetching application from active directory. Total number of applications are increased and now they are above 999. Maximum number of items in one page can be 999. I want to fetch all applications in one page collection. I am using following code to fetch applications, but it seems that there is no method in activedirectory client to return all apps in one call.
Can I make collection of pages and append all pages using do while?
IPagedCollection<IApplication> applications = null;
applications = await activeDirectoryClient.Applications.Take(999).ExecuteAsync()
You can try to get all the applications like this:
List<IApplication> applicationList = new List<IApplication>();
IPagedCollection<IApplication> pagedCollection = activeDirectoryClient.Applications.ExecuteAsync().Result;
do
{
applicationList.AddRange(pagedCollection.CurrentPage.ToList());
pagedCollection = pagedCollection.GetNextPageAsync().Result;
} while (pagedCollection != null && pagedCollection.MorePagesAvailable);