LdapPage[] and InPagesOf<T> Question

Mar 15, 2012 at 5:04 PM

I have been looking for something that would execute an IQueryable object into an IEnumerable<ILdapPage<T>>.

Things were hopeful when I found PageAll<T>() (which turned out to be obsolute) and InPagesOf<T>(), but realized that these methods are designed to return the query results in a List<T> instead of List<ILdapPage<T>>.

Could you tell me in what case that the InPagesOf<T>() would be preferred over .ToList<T>()?

Is there any existing functionality that store IQueryable results into an IEnumerable<ILdapPage<T>>? I am interested in checking number of pages available for a query result, and referring to collection of pages without executing the query again.

Far out work man!

-campbeja

Coordinator
Mar 18, 2012 at 2:28 AM

InPagesOf is purely for more control.  You may want to override the default page size set on the ldap configuration.  InPagesOf and PageAll don't build an IEnumerable<ILdapPage<T>> because the idea behind those methods is to get everything so paging becomes moot.  If you wanted to do this yourself you could do something like this:

 

var pages = new List<ILdapPage<User>>();
var currentPage = context.Query<User>().ToPage(1000);
pages.Add(currentPage);
while (currentPage.HasNextPage)
{
    currentPage = context.Query<User>().ToPage(1000, currentPage.NextPage);
    pages.Add(currentPage);
}