Click here to Skip to main content
12,750,710 members (36,728 online)
Rate this:
Please Sign up or sign in to vote.
When we should use the List<> object and when we should use the Dataset/Datatable object for fetching more than 10000 rows from database.
Posted 27-Nov-12 1:36am
digimanus 27-Nov-12 8:08am
well...if you have 10,000 records first in DataTable object and then set them to a List<>, that takes time you don't need. Better use SqlDataReader for speed.
But 10,000 to display? Your wenserver will not fetch that without some paging.
10,000 rows to process? Better do it in a database.
Mathlab 27-Nov-12 9:57am
If you are doing updates and inserts I use data table to preserve the format of the data. Once the data is in the Bussiness Logic or UI tier I like to use lists becasue I like to use LINQ.
Sergey Alexandrovich Kryukov 27-Nov-12 11:11am
Totally wrong question. Better for what?!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You probably meant to compare DataSet vs DataReader performance (because, in order to populate your list you need to somehow access the database).
Here you have a good reference: "Performance Comparison: Data Access Techniques"[^].
Master.Man1980 27-Nov-12 15:08pm
good one
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

if u don't care about how you are fetching data using dataadapter/ datareader but wants to know which data source collection will be helpful to u. U have to 1st think about what are u going to do with your data.
Datatable and dataset are good but heavy collection compare to other collections like list,array,dictionary etc. but Very useful (they have built-in many functionality like sort,filter, parent - child relation and many more). As their base is XML they are most portable collection with any system which support xml. WCF,web service absorb them easily without much help.
Now if you don't want above functionality. List ,array are better option.But still there is lot of secrets of optimization and performance.
If want to know real difference of such collections , follow this link[.Net Collection].[.Net Optimization]

If u like this solution ,plz accept as answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If you are fetching data from a database, you are likely grabbing more than one column of data. In that case, you should use a DataSet[^] and DataTable[^], which handle both columns and rows of data.

Lists[^] are like arrays in that they are a single collection. You'd use them if you had a simple one column list of data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170215.1 | Last Updated 16 May 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100