Is there a paging solution for ASP.NET MVC that does paging in the database?

前端 未结 4 1709
小蘑菇
小蘑菇 2021-02-02 17:35

Most of the ASP.NET MVC paging solutions I have found by googling look like they get all rows from a database table in the form of a IEnumerable collection, perform some paging

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 17:50

    wouldn't it be more efficient to implement a stored procedure that takes @StartPage and @PageSize parameters?

    this way you are only retrieving the subset of data that is actually being used

    just have an out parameter called totalCount or something similar so that you know how many page links to create and each link onclick event will pass the page number to a javascript function that will asynchronously load the div or other HTML element with more data

    easy

提交回复
热议问题