DB data into a custom list...

  • Thread starter Thread starter Colin Basterfield
  • Start date Start date
C

Colin Basterfield

Hi,

As I've decided to use my own custom collections to get data from my DB
backend, to a web service, and then to my client frontend, I was wondering
if there is a way to directly fill the objects of my collection without
first having to load into a DataSet.

Could I override the SqlDataAdapter.Fill method so instead of
dbAdapter.Fill(dataSet, "site"), I have dbAdapter.Fill(myList, "site"), and
then the Fill would simply map the fields of each row onto the object fields
followed by adding them to the list?

What about SqlDataReader, does that give me any more options?

Is this a reasonable idea, or should I get my coat?

Thanks in advance
Colin B
 
Hi Colin,

Colin Basterfield said:
Hi,

As I've decided to use my own custom collections to get data from my DB
backend, to a web service, and then to my client frontend, I was wondering
if there is a way to directly fill the objects of my collection without
first having to load into a DataSet.

There is.
Could I override the SqlDataAdapter.Fill method so instead of
dbAdapter.Fill(dataSet, "site"), I have dbAdapter.Fill(myList, "site"), and
then the Fill would simply map the fields of each row onto the object fields
followed by adding them to the list?
Nope.

What about SqlDataReader, does that give me any more options?

Yes. if is a forward read only sort of cursor. You go reading row by row.
Is this a reasonable idea, or should I get my coat?

Reader is a good idea for your purpose.
 
Back
Top