New Posts New Posts RSS Feed: Bug in PagedRdbQuery?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Bug in PagedRdbQuery?

 Post Reply Post Reply
Author
evanian View Drop Down
Newbie
Newbie


Joined: 23-Apr-2010
Posts: 7
Post Options Post Options   Quote evanian Quote  Post ReplyReply Direct Link To This Post Topic: Bug in PagedRdbQuery?
    Posted: 17-May-2010 at 2:10am
I have a PagedRdbQuery object, with its PagesShouldOverlap property set to False.  Its PageSize property is set to 15 (the exact value is unimportant here, however).

The problem is this.  As long as I call NextPage() on the PagedRdbQuery, it returns the expected number of entities - 15, in this case.  However, if I call PrevPage(), the number of entities returned is PageSize -1, or in this case, 14.  The last entity in the set  for that page (the set that had been returned for that page when NextPage() was called earlier) is now missing.  The same is true for any pages that you reach by calling PrevPage().  Worse, those entities stay missing even if you move into those pages by calling NextPage() from an earlier page. 

This issue does not occur if PagesShouldOverlap is set to True.


I wonder if this issue is one you've seen before?  Any help would be appreciated!  I'm using IdeaBlade assemblies with Runtime Version v2.0.50727.


Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 17-May-2010 at 11:37am
I could not duplicate this behavior.  My code worked fine,  Try this (from Reference Help):
 

static void Main(string[] args)

{

PersistenceManager pm = PersistenceManager.DefaultManager;

// Query orders in descending date sequence.

RdbQuery aQuery = new RdbQuery(typeof(Order));

aQuery.AddOrderBy(Order.OrderDateEntityColumn, System.ComponentModel.ListSortDirection.Descending);

// Build a paged query to retrieve 10 items at a time.

PagedRdbQuery pagedQuery = new PagedRdbQuery(aQuery);

pagedQuery.PageSize = 10;

pagedQuery.PagesShouldOverlap = false;

while (true) {

EntityList<Order> orders = pm.GetEntities<Order>(pagedQuery);

Console.WriteLine("Current page = " + pagedQuery.CurrentPage.ToString());

Console.WriteLine("Order count for this page = " + orders.Count.ToString());

foreach (Order anOrder in orders) {

Console.WriteLine(" Order id = " + anOrder.Id.ToString());

}

// to stop the window from going away

Console.WriteLine("\n\nPress Enter to continue");

Console.ReadLine();

if (pagedQuery.IsLastPage) break;

// Advance the query.

pagedQuery.NextPage();

}

}

}

}

Back to Top
evanian View Drop Down
Newbie
Newbie


Joined: 23-Apr-2010
Posts: 7
Post Options Post Options   Quote evanian Quote  Post ReplyReply Direct Link To This Post Posted: 18-May-2010 at 3:47am
Thanks for the prompt reply.  I notice that your sample code doesn't include any calls to PrevPage(), which is where the problem occurs for me -- have you tried that?

When I adapt your code to suit my database  the problem recurs.    Here's the output, followed by the adapted code.

--------------------------------------------------------------------------------

Output:

Moving ahead one page...
Current page = 2
Employer count for this page = 10

Moving ahead one page...
Current page = 3
Employer count for this page = 10

Moving ahead one page...
Current page = 4
Employer count for this page = 10

Moving back one page...
Current page = 3
Employer count for this page = 9

Moving back one page...
Current page = 2
Employer count for this page = 9

Moving back one page...
Current page = 1
Employer count for this page = 9

Moving ahead one page...
Current page = 2
Employer count for this page = 9

Moving ahead one page...
Current page = 3
Employer count for this page = 9

Moving ahead one page...
Current page = 4
Employer count for this page = 9

Moving ahead one page...
Current page = 5
Employer count for this page = 10


--------------------------------------------------------------------------------

Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IdeaBlade.Persistence.Rdb;
using IdeaBlade.Persistence;
using Model;
using IdeaBlade.Rdb;
using System.Reflection;

namespace PagingTest2
{
    public partial class IdeabladeSample : Form
    {
        PagedRdbQuery _pagedQuery;

        public IdeabladeSample()
        {
            InitializeComponent();
            RunQuery();
        }


        private void RunQuery()
        {
            PersistenceManager pm = PersistenceManager.DefaultManager;

            // Query orders in descending date sequence.
            RdbQuery aQuery = new RdbQuery(typeof(AS400Employer));

            aQuery.AddOrderBy(AS400Employer.EmployerEntityColumn, System.ComponentModel.ListSortDirection.Descending);

            // Build a paged query to retrieve 10 items at a time.
            _pagedQuery = new PagedRdbQuery(aQuery);
            _pagedQuery.PageSize = 10;
            _pagedQuery.PagesShouldOverlap = false;

            MoveNext();
            MoveNext();
            MoveNext();

            MovePrevious();
            MovePrevious();
            MovePrevious();

            MoveNext();
            MoveNext();
            MoveNext();
            MoveNext();

        }

        private void MoveNext()
        {
            MoveQuery(true);
        }

        private void MovePrevious()
        {
            MoveQuery(false);
        }

        private void MoveQuery(bool forward)
        {
            // Move either foward or back
            if (forward)
            {
                WriteLine("Moving ahead one page...");
                _pagedQuery.NextPage();
            }
            else
            {
                WriteLine("Moving back one page...");
                _pagedQuery.PrevPage();
            }

            PersistenceManager pm = PersistenceManager.DefaultManager;

            EntityList<AS400Employer> employers = pm.GetEntities<AS400Employer>(_pagedQuery);
            WriteLine("Current page = " + _pagedQuery.CurrentPage.ToString());

            WriteLine("Employer count for this page = " + employers.Count.ToString());

            WriteLine("");

        }

        private void WriteLine(string s)
        {
            Console.WriteLine(s);

            if (txtDisplay.Text == "")
                txtDisplay.Text = s;
            else
                txtDisplay.Text += Environment.NewLine + s;
        }
    }
}

Back to Top
foxs View Drop Down
Newbie
Newbie


Joined: 06-Jul-2011
Posts: 1
Post Options Post Options   Quote foxs Quote  Post ReplyReply Direct Link To This Post Posted: 06-Jul-2011 at 8:26pm
I'm currently experiencing the same problem, any idea on how to fix this?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jul-2011 at 10:32am
We've confirmed this as a bug.  Sorry, we don't have a workaround, other than to set overlap to true when possible.  We hope to have this fixed in the next release.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down