Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataTable and DataSet should be obsolete now?

Is there any valid use case for DataSet and DataTable now that we have Entity Framework? Should DataTable/DataSet be considered obsolete?

like image 969
Muhammad Hasan Khan Avatar asked Apr 05 '11 06:04

Muhammad Hasan Khan


People also ask

Which is better DataSet or DataTable?

If we are going to fetch data from a single database table then DataTable is better choice. While DataSet on the other hand can define DataRelations - which define the relationship between DataTables, much like a foreign key relationship can be set up between tables in a database.

What is difference between DataTable and DataSet?

DataSet comprises one or many dataset tables which have the in-memory feature. DataTable holds a single or unit database table that has an in-memory feature. DataSet is formed collectively of datatables. DataTable is composed of multiple rows and columns to have better access to data.

Which is faster DataReader or DataTable?

DataReader is used to read the data from the database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset.

What is alternate of DataTable in C#?

And then a DataTable alternative is simply a List<Dictionary<string, Cell>> . Let's say you define Rows as public List<Dictionary<string, Cell>> Rows; .


2 Answers

When you know the data schema at compile time then I'd EF would be all you need. However, there are situation where you're getting data from a service and you don't know what the schema/datatypes will be ahead of time. I think DataSet/DataTable would still be useful in that kind of scenario.

like image 123
Andrew Cooper Avatar answered Oct 06 '22 00:10

Andrew Cooper


I wouldn't go as far as calling them obsolete. I still use datasets when gathering data from several different datasources; xml-files, databases, etc. Then I can use LINQ to DataSet to manipulate data from the different sources.

I believe there may be other scenarios as well where datasets will be the right fit.

like image 28
Nils Magne Lunde Avatar answered Oct 06 '22 00:10

Nils Magne Lunde