[2.0] DataSet v Object storage
Recently had an interview and ask how I handled data from a DB, I said i just use a datareader to read the data into an object/Collectionwith fields mapped to the info downloaded, the interviewer looked as if i pi$$ed n his shoes and told me the only and best Way was via Datasets and Datatables When i tried to explain i found this method of data access a bit to procreative I could tell I wold not get the job. So just wondering how you guys go about it I know my method works but should i truly embrace the full features of ADO.Net ?
Thanks!!
:wave: :thumb: :wave:
Re: [2.0] DataSet v Object storage
I would really have to recommend you give datasets and datatables a try. Especially with the .net 2.0 stuff where you link your SQL statements into a tableadapter.
Datasets do have a large overhead, in terms of memory and speed. However a dataset is more logically similar to the data you have stored in a database.
Personally I nearly always use datasets. I would really recommend that you give them a go!
Re: [2.0] DataSet v Object storage
There are always multiple ways to divest a feline of it epidermis, and many often have merit. Using objects and strongly typed collections for data is of most use in a distributed system. Untyped DataSets are not ideal purely for the fact that they are untyped. Getting data from an untyped DataSet is like using late-binding or reflection. It is convenient but there's no help from the IDE and a single character out of place, which the IDE won't pick up, could cause your app to crash at run time. Strongly-typed DataSets don't have this issue and VS 2005 gives you lots of help to create them. Each DataRow from a strongly-typed DataSet already IS an object with appropriately named and typed properties corresponding to each column. Declaring your own types is simply reinventing the wheel. That doesn't mean that other methods are not valid, but there is no genuine reason that I can see that you shouldn't use strongly-typed DataSets. I guess the one major advantage of using your own types is that you can still give them other members that a strongly typed DataRow will not have.
Re: [2.0] DataSet v Object storage
The answer is C - it depends. Just like any other tool, you use the right one for the right job. If you need to put a nail into a wall, you use a hammer, not a screwdriver. Conversly when dealing with screws, you use the screwdriver.
The is no one right answer.... sometimes I find a dataset more convienient than collections and objects.... sometimes the other is true.
-tg