Return required rows and total row count

Topics: General Discussion Forum, July and December Releases Forum
Oct 31, 2007 at 9:42 PM
Lets explain this with an example . I have a table with 1 million rows.
I would like to call the stored procedure with the start and end index. which returns me the result set. (This can be done with Dec 06 release)
Now I would also like to know the total number of rows that fit the bill.

This way I get the rows required and the total row count which helps me with paging.
I could make 2 calls but that would be daft. Any suggestions ??
Nov 1, 2007 at 11:19 AM
It sounds like your result from your call shouldnt be resultset but an object that wraps the result set and has an totalrows property.

class ResultSetWrapper
public List<BusinessEntity> resultset;
public int totalRows;

Nov 1, 2007 at 8:08 PM
Hi Benny,
I have tried this implementation. When you try to use the service factory to use this.
You get two options in the left the Class and the NumberOfRows. And on the right you have the various columns of the result set and DONT GET THE NumberOfRows OUT parameter of the stored procedure.

Nov 6, 2007 at 9:09 AM
Edited Nov 6, 2007 at 9:23 AM
Some times you have to do some work on your own.

Just add this later.
Nov 6, 2007 at 10:28 AM
Hi Benny,
You are right. and it took me a few days to get it. Lets call it a couple of weekends.
I created a template class in BusinessEntities which took the Classname as the List object.

Then I made repository as a partial class and added another template based function which read the reader and got your business objects and also got the row count. Actually it was getting the total rowcount which was something I didn't know how to do. But figured that out as well.
Because in any other case I would have had to make two SP calls and maintain twice as many stored procedures and that's something I was not willing to do.

Code is available at request and with the brilliant response/ help on this discussion forum available at a premium.