PagedCollection class problem???

Sep 17, 2008 at 8:49 AM
Edited Sep 17, 2008 at 10:02 AM
PagedCollection using PagedCollectionEnumerator class as a Enumerator, why you using this?

I have this problem: Total 5 item, page size is 3, page index is using foreach statement
to loop through this collection, is will have total 5 item (3 item have value, 2 item is null)
what I expect is 3 item of current page.

And finally my solution is: not using PagedCollectionEnumerator class,
return list.GetEnumerator directly

public IEnumerator GetEnumerator()
{
return list.GetEnumerator();
}
Coordinator
Sep 17, 2008 at 9:10 AM
Please use PagedSelector and PagedCollection, don't use PagedCollectionEnumerator directly.
And please reference the code in Orm-08 in samples.
Sep 17, 2008 at 10:06 AM
In example Orm08, the method Show() will loop 8 time for each page, only 2 item have data, instead pagesize = 2.

What I think is each page where just have 2 item to loop, so we do not need to check if the object is null.

        private static void Show(string ShowString, ICollection ic)
        {
            Console.WriteLine("-------------------------------------------");
            Console.WriteLine(ShowString);
            int i = 0;
            foreach (object o in ic)
            {
                Console.Write("({0})", ++i);
                if (o == null)
                {
                    Console.WriteLine("<NULL>");
                }
                else
                {
                    Console.WriteLine(o);
                }
            }
            Console.WriteLine();
        }
Coordinator
Sep 17, 2008 at 12:52 PM
Add the following lines to Orm-08:

            Show("Use IPagedSelector.GetCurrentPage(3):", ps.GetCurrentPage(3));

            Show("Use IPagedSelector.GetCurrentPage(4):", ps.GetCurrentPage(4));