DataReader的或数据集拉动ASP.NET多个记录集时 [英] DataReader or DataSet when pulling multiple recordsets in ASP.NET
问题描述
我有一个有一堆的需要填充(例如下拉列表)控制的ASP.NET页面。
我想作单趟db和带回多个记录,而不是使每个控制往返的。
我可以带回多个表在DataSet,我也可以带回一个DataReader和使用.NextResult把每个结果集到一个自定义公务舱。
我将有可能使用DataReader的方法看到一个足够大的性能优势,或者我应该只使用DataSet的方法呢?
你通常如何处理这将是AP preciated任何例子。
- 如果您有超过1000 记录从数据库带来的。
- 如果您是不是很感兴趣
定制的存储和自定义分页
对于GridView控件的 - 如果你的服务器有内存压力。
- 如果没有连接到问题
你的数据库的每一次页面
调用。
那么我认为更好的是使用DataReader的。的
其他
- 如果您有少于1000 记录从数据库带来的。
- 如果您有兴趣与
存储和分页的有关
GridView控件的 - 如果您的服务器没有内存
压力。 - 如果您想连接到您的
数据库只是一个时间和得到
利益的缓存
那么我认为更好的是使用的数据集。的
我一跳,我是对的。
I've got an ASP.NET page that has a bunch of controls that need to be populated (e.g. dropdown lists).
I'd like to make a single trip to the db and bring back multiple recordsets instead of making a round-trip for each control.
I could bring back multiple tables in a DataSet, or I could bring back a DataReader and use '.NextResult' to put each result set into a custom business class.
Will I likely see a big enough performance advantage using the DataReader approach, or should I just use the DataSet approach?
Any examples of how you usually handle this would be appreciated.
- If you have more than 1000 record to bring from your DataBase.
- If you are not very interested with custom storing and custom paging "For GridView"
- If your server have a memory stress.
- If there is no problem to connect to your DataBase every time that page called.
Then i think the better is to use DataReader.
else
- If you have less than 1000 record to bring from your DataBase.
- If you are interested with storing and paging "For GridView"
- If your server haven't a memory stress.
- If you want to connect to your DataBase just one time and get the benefits of Caching.
Then i think the better is to use DataSet.
I hop that i'm right.
这篇关于DataReader的或数据集拉动ASP.NET多个记录集时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!