Click to See Complete Forum and Search --> : (DataReader + Struct) vs DataSet


wackoyacky
05-11-2007, 04:43 AM
As we all know that DataReader is faster than Dataset, but DataReader maintains a connection with the database and cannot be disconnected until the last record is read.

So what I did was I created a Struct that defines the fields that are being returned and populate this Struct with the DataReader and return the Struct to the UI. My question is, is this still faster than passing DataSet instead on each layer?

Cstick
05-12-2007, 10:28 PM
The Fill method of the SqlDataAdapter class actually uses an IDataReader. It fills a dataset or datatable and then closes the reader. You can probably get a little bit more performance out by using a structure like you are, but it is negligible and in most circumstances won't get noticed.

Personally, I prefer to use my own business entities, like you've done. Not for a performance gain though, but because I think datasets are cumbersome to work with. I use a framework very similar to Rockford Lhotka's CSLA.Net (http://www.lhotka.net/).

wackoyacky
05-12-2007, 10:55 PM
Thanks Cstick for your response, it is really helpful to get some insights from other people.

I do also prefer creating my own business entities, though it requires a lot of work compared to using datasets directly.

Thanks.