使用自定义逻辑在MVC中分析大量数据 [英] Paging on large amounts of data in MVC using custom logic

查看:73
本文介绍了使用自定义逻辑在MVC中分析大量数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想对大量数据实施 Paging 搜索排序(比如说) DB在 MVC 中有25到30个Lakhs的记录。在MVC中使用默认分页选项时(使用

 PagedList.Mvc 

 @ Html.PagedListPager 

为DB&提取所有记录;页面上只显示100条记录。这就是消耗时间和使用更多内存。

如何在MVC中实现自定义逻辑,每页只检索100条记录。目前我正在尝试这两种方法(使用EF和SP)。

任何建议。



我尝试过:



我已经使用EF& SP开发了示例应用程序并实现了默认分页。但是这两种方法都从DB&检索所有记录,然后在客户端应用分页。这太耗时了。

解决方案

很抱歉,但您没有提供有关您使用的方法的信息。所以...



我建议读这个:

大的分页ASP.NET中的结果集 [ ^ ]。

实体框架中的动态分页 [ ^ ]

使用SQL脚本进行高效分页 [ ^ ]


使用EF,之前我的操作方法是 -

  public  ActionResult索引( int ?页)
{
return 查看(db.TestUploadData2.ToList()。ToPagedList(page ?? 1 100 ));
}





但问题是.ToList()将所有内容从DB拉入C#内存然后获取所需的100条记录增加执行时间&记忆消耗。

使用以下代码解决了我的问题(使用EF方法)



  public  ActionResult索引( int ?page)
{
return 视图(db.TestUploadData2.OrderBy(x = > x.SrNo).ToPagedList(page ?? 1 100 ));
}





使用SP方法我编写了SP,它将PageNo作为参数&从DB&中返回总记录该页面的100条记录。

但是我的问题是如何在View中显示寻呼机控件。



SP方法的任何建议。 ....


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.

解决方案

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[^]


Using EF, previously my action method was -

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)

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.....


这篇关于使用自定义逻辑在MVC中分析大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆