Adding additional ResultSets to an IDataReader

J

Jeff

Hello,

I am using an object oriented approach that passes a datareader object from
a parent object down to it's children. When I use this approach with MS
SqlServer I just run a stored procedure that includes 2 select statements
and use the DataReader.NextResult when I need to get to the second
resultset.

The problem is that for this project I am being forced to use a database
which does not have the capability to return multiple resultsets via one hit
to the database (Intersystems Cache database). Since I really don't want to
have to change my framework model, I am looking for alternatives. What I
have come up with as a possibility is; Create a custom DataReader object
implementing IDataReader. My custom object should have a way to add
resultsets. If I can do this, I will be able to make multiple calls to Cache
(individual selects) and call a CustomDataReader.ResultSets.Add(<new
datareader results>). That way, once it's populated I can use the datareader
just as I always have using CustomDataReader.NextResult() to get to my data.

I think I see a few different ways to do this, but I wanted opinion from
others. I could internally store a List (Of DataReader) and then have
nextresult iterate those ( remember I can only get 1 resultset back from the
db per datareader). I could get the rows back and store it internally and
iterate an internal list (read and store just the data), etc.

Suggestions are welcome!

Thanks for taking the time, sorry about the lengthy post.

Jeff
 
J

Jeff

Sahil,

I am using 2.0, but it looks like a chore to setup the array of datatables
every time I want to create the reader. I think it would be easier if it
took in a dataset and read in the tables, but there doesnt look like a way
to do that.

You are correct though, it is an alternative. Thanks for the thoughts! I
didnt even know that reader existed.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top