Print Page | Close Window

EntityQueryPager Question

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3045
Printed Date: 16-Sep-2025 at 10:33pm


Topic: EntityQueryPager Question
Posted By: Vonzkie
Subject: EntityQueryPager Question
Date 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  http://drc.ideablade.com/ApiDocumentation/IdeaBlade.EntityModel~IdeaBlade.EntityModel.EntityQueryPager%601~TotalDataSourceItemCount.html - TotalDataSourceItemCount
and  http://drc.ideablade.com/ApiDocumentation/IdeaBlade.EntityModel~IdeaBlade.EntityModel.EntityQueryPager%601~TotalItemCount.html - 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



Replies:
Posted By: sbelini
Date 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.


Posted By: Vonzkie
Date 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


Posted By: Vonzkie
Date 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


Posted By: sbelini
Date 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.



Print Page | Close Window