Server Side Paging with stored procedures (not entity framework)

Apr 27, 2015 at 4:44 AM
Edited Apr 28, 2015 at 12:16 AM
Hi there,

Due to security restrictions I cannot use entity framework to generate queries, instead I must use stored procedures.

I'd like to pass the skip and the take into the stored proc and set a virtual count for the total number of items in the database.

At present the easiest option I've found is to load the complete table from the database and let grid.mvc, sort, filter and page in memory, obviously there are some scaling issues with this approach.

Another thought is to create a virtualised List with only the elements loaded for the page being displayed and the count on the list set to the virtual count. So...
// ...
// Call the storedProc populate pageFromSProc.
// ....

MyEntity[] virtualClx = new MyEntity[vitualCount];
pageFromSProc.CopyTo(virtualClx, skip);

return View(virtualClx);
Is this the easiest/best way to do this ?

This is a completely seperate issue, but whilst implementing this I've noticed the GridPager.CurrentPage is always 0 to get the current page I've had to write code....
            GridPager pager = new GridPager();
            string currentPage = Request.QueryString[pager.ParameterName];
            if (!string.IsNullOrEmpty(currentPage))
                return int.Parse(currentPage) - 1;
Shouldn't the last 3 lines be equivalent to pager.CurrentPage ?

Thanks

Mick