New Posts New Posts RSS Feed: EntityQueryPager Question
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityQueryPager Question

 Post Reply Post Reply
Author
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Topic: EntityQueryPager Question
    Posted: 20-Oct-2011 at 2:38am
Hi,

I'm trying to use EntityQueryPager<T> class to handle my paging activities but it seems that the TotalDataSourceItemCount
and TotalItemCount always return -1, what's the difference between the two?

What I'm trying to accomplish is to get the original item count from the datasource before the paging occurs.
Example if I have 10k records in the database and i paged it by 20, how can i get the count of 10k records?

Thanks,
Von
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 20-Oct-2011 at 5:37pm
Hi Von,

TotalDataSourceItemCount will return -1 until the last page is fetched via a call to MoveToLastPage.
TotalItemCount will return -1 until all pages are fetched or the TotalDataSourceItemCount is known.

While TotalDataSourceItemCount returns the count of records available to be returned from the datasource, TotalItemCount will also include items only present in the client.

If you want to retrieve the total item count before reaching the last page, you will need to query this value:

var totalCount = mgr.Employees.Count();

Regards,
   Silvio.
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 20-Oct-2011 at 7:25pm
Hi Silvio,
 
Hmmm.. does it mean that I need to view all page before I can get the TotalDataSourceCount or just a call to the last page will do?
 
Thanks,
VOn
Back to Top
Vonzkie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 01-Aug-2011
Location: PH
Posts: 133
Post Options Post Options   Quote Vonzkie Quote  Post ReplyReply Direct Link To This Post Posted: 20-Oct-2011 at 7:34pm
Hi Silvio,
 
Got it, it works when the MoveToLastPage() is called but I'm just curious if this process is the same as loading all the records then you're paging it in the client side? Because if that's so, it will be a huge delay when concerning ten thousands of records.
 
I need to get the totaldatasource count in order to compute the pagecount (TotalDataSourceCount / PageSize).
I think it's better if you have a PageCount property as well as TotalDataSourceCount that doesn't need to call the MoveToLastPage() in order to get the count of the records from the datasource.
 
Thanks,
Von
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 21-Oct-2011 at 1:10pm
Hi Von,

You won't be loading all records in the client when calling MoveToLastPage().
You won't load all records if you use Count() as well.

If you want to retrieve this value without having to call MoveToLastPage(), I suggest using Count(). This way you will be able to get the pagecount.

Regards,
   Silvio.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down