Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I want to implement Paging, Searching, Sorting on large amount of data (say DB has 25 to 30 Lakhs of records) in MVC. While using default paging option in MVC (using
PagedList.Mvc
,
@Html.PagedListPager
all records are fetched for DB & only 100 records are displayed on page. Thats Time Consuming & used more Memory.
How can I implement Custom Logic in MVC that only retrieves exact 100 records per page. Currently I am trying both approaches (using EF and SP).
Any Suggestion.

What I have tried:

I have already developed sample applications using EF & SP and implement default paging. But both approaches retrieves all records from DB & then apply paging on client side. Thats too much time consuming.
Posted
Updated 26-Aug-16 4:09am
v2
Comments
Umesh AP 26-Aug-16 7:53am    
@Maciej Los - As I already told I made sample applications using EF & SP with default paging but drawback of this is that every time I moved to next page whole set of data retrieves from DB & then paging is performed on client. I don't want whole data every time, but i want only 100 records to be fetched from DB for that page & when user changes page, only respective 100 records needs to retrieve from DB & displayed on view.

Sorry, but you didn't provide information about method you use. So...

I'd suggest to read this:
Paging of Large Resultsets in ASP.NET[^].
Dynamic paging in Entity Framework[^]
Efficient paging using SQL script[^]
 
Share this answer
 
Comments
Umesh AP 26-Aug-16 10:05am    
@Maciej - Thanks for ur support.
Maciej Los 28-Aug-16 7:03am    
You're very welcome.
Using EF, previously my action method was -
C#
public ActionResult Index(int? page)
{
      return View(db.TestUploadData2.ToList().ToPagedList(page ?? 1, 100));            
}


But problem is that .ToList() pulls everything from DB into C# memory and then getting required 100 records which increases execution time & memory consumption.
Using following code solves my problem (using EF approach)

C#
public ActionResult Index(int? page)
{
      return View(db.TestUploadData2.OrderBy(x => x.SrNo).ToPagedList(page ?? 1, 100));
}


With SP approach I wrote SP which takes PageNo as parameter & returns total records from DB & 100 records for that page.
But here my problem is that how to display pager control in View.

Any suggestion for SP approach.....
 
Share this answer
 
Comments
Maciej Los 28-Aug-16 7:06am    
This is not an answer. Please, delete it to avoid down-voting. Use Improve question widget to be able to upgrade your originall question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900