views:

196

answers:

4

So I had an architect on a previous project who railed against Datasets. He hated them, and said they had no place in a web application, specifically a web app which will have a lot of traffic.

I've noticed in many instances of code I've taken over that Datasets are used quite heavily.

Are they really that bad/performance killing?

Should I think about gutting the application of it's heavy use of datasets and replace them with lists populated via data readers?

I'm curious to hear what you all have found on the topic, or what your preference is.

Thanks again guys!data

+2  A: 

Dino Esposito article DataSets vs. Collections might be a good reference in comparing between using Dataset vs Collections.

My preference is using Domain (Business Objects) and Collections by following the concept of Domain Driven Design combined with using NHibernate for the data persistence and also Dependency Injection

hadi teo
+1  A: 

I don't have anyproblem with Datasets though I would expect that I would find performance problems if I stored alot of them in Session (particularily an out of process provider) or had to serialize them across a web service call. For the most part in reasonably simple two or small three teir structures I haven't found them a problem.

I would also attempt to make sure that the data layer wasn't returning more data than I acutally needed for the page.

David McEwing
+1  A: 

Datasets are basically a small, in-memory database, which is why you were told that, in a web application with a large number of users, datasets will not scale well, because they will use up memory on the web server.

Whether or not you should replace the datasets in your current application depends on whether or not your application is having problems scaling (working with a significant number of users) because of the datasets.

I too prefer using more sophisticated tools to build web applications, but I hesitate to throw a lot of ten dollar words at you if you are still using datasets and dataadapters to run your web application. Datasets and data adapters are a perfectly good way to build a website.

The thing you have to remember about a dataset is that it is an in-memory representation of data, and it is randomly accessible; whereas a data adapter is a forward-only reader, but it is very fast and it requires very little memory (enough for a single record). A dataset in a web application should typically be kept very small if possible.

Robert Harvey
A: 

Performance isn't a real concern unless you have a reason for it to be. Performance with datasets can be either quite good or quite poor, depending on how you use them -- that's the important thing.

The real PITA with datasets is that they're relatively hard to work with in comparison to the much richer technologies that you have at your disposal like LINQ 2 SQL/Entities and NHibernate. They're also a pain to use regular LINQ over, compared to object collections.

Dave Markle
I've had great success using Linq to Datasets. http://msdn.microsoft.com/en-us/library/bb386977.aspx
itchi