在调用方法之前填充数据集 [英] Fill dataset before calling method

查看:94
本文介绍了在调用方法之前填充数据集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。



我有一个带有表单和提交按钮的MVC项目。

将值传递给控制器​​。一种方法将根据传递的参数从数据集中获取数据。然后一些VB函数将与检索到的数据一起工作。

目前我在ajax之后填充了整个数据集。



我的问题是db非常大,获得结果所需的时间比我想要的要多。



我试图在windows.onload上填充数据集,只需要一个特定的函数对于那个在同一个控制器中,但是那个方式,当进行ajax调用时,没有填充数据集。



这是可能的,我只需要以正确的方式进行或者它必须在ajax调用后填写吗?



谢谢

Hi.

I have a MVC project with a form and a submit button.
The values are passed to the controller. One method will fetch data from the dataset according to the parameters passed. Then some VB functions will work with the data retrieved.
Currently I have the whole dataset being filled after the ajax.

My problem is the db is very big and it takes more time to get the results than I wish to.

I tried to fill the dataset at windows.onload puting a specific function just for that in the same controller but that way when the ajax call is made there's no dataset filled.

Is this possible and I just need to do it the right way or it has to fill after the ajax call?

Thanks

推荐答案

如你所说,
引用:

db非常大,需要更多时间才能得到结果

db is very big and it takes more time to get the results



所以看来你好像在拿更多数据,在页面加载时你可以在屏幕上显示



在这种情况下看来,分页会有所帮助。因此,最初进行查询以仅获取数据(或更多)哪个网页可以向用户显示然后逐步增加您可以在用户点击特定页码时加载更多数据。因此,您还需要优化对数据库的查询。



ASP.NET MVC中有许多可用于分页的示例。我不确定您是否在项目中使用Entity框架或ADO.NET,请搜索相应的代码示例。



为了快速了解分页,请查看on:

http://devproconnections.com/aspnet-mvc/ aspnet-mvc-paging-done-perfect [ ^ ]



http://www.asp.net/mvc /概要/工具入门/工具入门与 - 使用-MVC EF-/排序过滤和寻呼与 - 的实体框架功能于一个-ASP净MVC-应用 [ ^ ]



http://blogs.taiga.nl/martijn/2008/08/27/paging -with-aspnet-mvc / [ ^ ]



要获得更多优化,请在ASP.NET MVC中使用缓存来获取前几行数据....在数据库端,在适当的列上使用索引。



您最欢迎进一步查询。


So it seems you are fetching much more data, that what you can show on the screen at page load.

In this case it seems, pagination will help. So initially make a query to get only the data (or little more) which webpage can show to user and then incrementally you can load more data while user clicks on a particular page number. Accordingly you need to optimize query to database too.

There are many samples available for pagination in ASP.NET MVC. I am not sure whether you are using Entity framework or ADO.NET in your project, please search for appropriate code samples.

For quick idea of pagination, have a look on:
http://devproconnections.com/aspnet-mvc/aspnet-mvc-paging-done-perfectly[^]

http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/sorting-filtering-and-paging-with-the-entity-framework-in-an-asp-net-mvc-application[^]

http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/[^]

For more optimization, use caching in ASP.NET MVC for first few rows of data ....and at database side, use indexing on appropriate columns.

You further queries are most welcome.


我很笨!我只需要填写我需要的数据。
i'm dumb! I just need to only fill with the data I need.


这篇关于在调用方法之前填充数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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