将数据绑定到强类型下拉列表需要花费更多时间在mvc5中 [英] Binding data to strongly typed dropdownlist taking more time in mvc5

查看:84
本文介绍了将数据绑定到强类型下拉列表需要花费更多时间在mvc5中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我正在尝试在强类型下拉列表中绑定大约2万卢比的数据(ItemId,ItemCode)。使用存储过程从DB表中获取数据。在应用程序中,使用实体框架来调用存储过程。



Hi..
I'm trying to bind around 2 lakhs of data(ItemId,ItemCode) in a strongly typed drop down list. Using stored procedure to fetch data from DB table. In application, Using entity frame to invoke stored procedure.

public IEnumerable<OPS_GetATCCItems_Result> GetItemMaster_ATCC
       {
           get
           {
               EntityDataModel.StoredProcedures.MastersSPsEntities db = new MastersSPsEntities();
               ItemViewModel _ivm = new ItemViewModel();
               _ivm.getAtccItemMasterDtls_resultList = db.OPS_GetATCCItems().ToList();
               return _ivm.getAtccItemMasterDtls_resultList;
           }
       }





以上功能从DB获取数据。





Above function fetch data from DB.

@Html.DropDownListFor(m => Model.getItemRecmdDtls_result.ItemMasterId, new SelectList(Model.ddlContr.GetItemMaster_ATCC, "ItemMasterId", "LgcCode"), "Select",
                                                                      new { @id = "ddlItemCode", @style = "width:280px !important;", @class = "select2", @required = "Required", @title = "Item Code is required." })





以上语句将数据绑定到下拉列表。



任何帮助表示感谢。



谢谢。



我尝试了什么:



存储过程约需25秒执行。下拉列表绑定会占用更多时间。



Above statement to bind data to dropdownlist.

Any help appreciated.

Thank you.

What I have tried:

Stored procedure taking around 25secs for execution. Drop down list binding comsuming more time.

推荐答案

将20万个项目加载到列表中是不可行的选择。除了执行查询和加载项目所需的时间长度之外,您将对服务器的内存以及客户端的带宽,内存和电池寿命施加巨大压力。



而且它无法实现任何目标。如果用户可以每秒查看一个项目,则需要超过55个半小时才能滚动列表以找到他们想要的项目。



基于CSS类,您已经在使用 Select2 [ ^ ]让他们搜索列表。使用远程数据选项 [ ^ ]仅加载与用户搜索的内容相匹配的项目。如有必要,请使用分页选项 [ ^ ]限制单个回复中返回的项目数。
Loading two hundred thousand items into a list is not a viable option. Aside from the length of time it will take to execute the query and load the items, you'll be putting huge pressure on the server's memory, and the client's bandwidth, memory, and battery life.

And it wouldn't achieve anything. If the user could look at one item every second, it would take them over 55½ hours to scroll through the list to find the one item they want.

Based on the CSS class, you're already using Select2[^] to let them search the list. Use the "remote data" option[^] to only load the items which match what the user is searching for. If necessary, use the pagination option[^] to limit the number of items returned in a single response.


这篇关于将数据绑定到强类型下拉列表需要花费更多时间在mvc5中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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