问题描述
我目前使用的DataTable从中我可以在我的code使用的数据库得到结果。
I currently use a DataTable to get results from a database which I can use in my code.
然而,大量的实例上使用DataSet,而不是通过集合方式访问表(S)的web显示。
However, many example on the web show using a DataSet instead and accessing the table(s) through the collections method.
它有什么优势,性能明智或以其它方式使用数据集或数据表作为SQL结果的存储方法?
Is there any advantage, performance wise or otherwise, of using DataSets or DataTables as a storage method for SQL results?
推荐答案
这真的取决于那种你带回的数据。由于DataSet是(实际上)只是一个DataTable对象的集合,可以返回多个不同的数据集到一个单一的,因此更易于管理,对象。
It really depends on the sort of data you're bringing back. Since a DataSet is (in effect) just a collection of DataTable objects, you can return multiple distinct sets of data into a single, and therefore more manageable, object.
性能方面,你更可能从比.NET结构的错误的选择未经优化的查询,得到的低效率。至少,这是我的经验。
Performance-wise, you're more likely to get inefficiency from unoptimized queries than from the "wrong" choice of .NET construct. At least, that's been my experience.
这篇关于数据表VS数据集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!