PC Review


Reply
Thread Tools Rate Thread

Datareader design not generic

 
 
Edward Diener
Guest
Posts: n/a
 
      10th Dec 2004
I would have expected an IDataReader to be able to return an IDataRecord
from some interface function for the current row, to allow one to fetch the
row and its values generically. But I did not find such functionality. Did I
miss it ? Why is IDataReader not designed as generically as the other ADO
..NET interfaces ?


 
Reply With Quote
 
 
 
 
Miha Markic [MVP C#]
Guest
Posts: n/a
 
      10th Dec 2004
Hi Edward,

If you look at classes that implement IDataReader, you'll see that they also
implement IDataRecord.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"Edward Diener" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I would have expected an IDataReader to be able to return an IDataRecord
>from some interface function for the current row, to allow one to fetch the
>row and its values generically. But I did not find such functionality. Did
>I miss it ? Why is IDataReader not designed as generically as the other ADO
>.NET interfaces ?
>



 
Reply With Quote
 
 
 
 
Edward Diener
Guest
Posts: n/a
 
      10th Dec 2004
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:%(E-Mail Removed)...
> Hi Edward,
>
> If you look at classes that implement IDataReader, you'll see that they
> also implement IDataRecord.


But classes which implement IDataReader are not generic. They are specific
to a particular implementation such as Oracle, SqlServer, OleDb, or Odbc.
That was my entire point of asking why IDataReader does not have a function
which returns an IDataRecord. Then implementation classes which implement
IDataReader could return their own version of IDataRecord. This would make
the IDataReader generic rather than specific to an implementation since
IDataRecord is generic enough to be used, as is, to return column values.
Nearly all other interfaces in ADO .NET can be treated generically in such a
way, with only a very small amount of implementation specific functionality
added for classes which implement the interface. Only IDataReader, among the
major interfaces, can not. One simply can not use IDataReader to get a row,
and therefore the values of the columns of that row, without using instead a
specific class which implements it.

>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> SLODUG - Slovene Developer Users Group
> www.rthand.com
>
> "Edward Diener" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I would have expected an IDataReader to be able to return an IDataRecord
>>from some interface function for the current row, to allow one to fetch
>>the row and its values generically. But I did not find such functionality.
>>Did I miss it ? Why is IDataReader not designed as generically as the
>>other ADO .NET interfaces ?
>>

>
>



 
Reply With Quote
 
Sahil Malik
Guest
Posts: n/a
 
      10th Dec 2004
Edward,

The generic is Odbc/OleDb. Although being generic it is upto 70% slower.

What is the specific business case in which you are running into this
"limitation". Not every ado functionality is a one to one map between ado
and ado.net. I'd like to know what you are trying to acheive in ADO, that
you are having problem achieving in ADO.NET.


- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



"Edward Diener" <(E-Mail Removed)> wrote in message
news:e5sHh#(E-Mail Removed)...
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:%(E-Mail Removed)...
> > Hi Edward,
> >
> > If you look at classes that implement IDataReader, you'll see that they
> > also implement IDataRecord.

>
> But classes which implement IDataReader are not generic. They are specific
> to a particular implementation such as Oracle, SqlServer, OleDb, or Odbc.
> That was my entire point of asking why IDataReader does not have a

function
> which returns an IDataRecord. Then implementation classes which implement
> IDataReader could return their own version of IDataRecord. This would make
> the IDataReader generic rather than specific to an implementation since
> IDataRecord is generic enough to be used, as is, to return column values.
> Nearly all other interfaces in ADO .NET can be treated generically in such

a
> way, with only a very small amount of implementation specific

functionality
> added for classes which implement the interface. Only IDataReader, among

the
> major interfaces, can not. One simply can not use IDataReader to get a

row,
> and therefore the values of the columns of that row, without using instead

a
> specific class which implements it.
>
> >
> > --
> > Miha Markic [MVP C#] - RightHand .NET consulting & development
> > SLODUG - Slovene Developer Users Group
> > www.rthand.com
> >
> > "Edward Diener" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >>I would have expected an IDataReader to be able to return an IDataRecord
> >>from some interface function for the current row, to allow one to fetch
> >>the row and its values generically. But I did not find such

functionality.
> >>Did I miss it ? Why is IDataReader not designed as generically as the
> >>other ADO .NET interfaces ?
> >>

> >
> >

>
>



 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      10th Dec 2004
it is generic. that what the IDataReader and IDataRecord intefaces are for.

IDataReader dr = createADataReader();
while (dr.read)
{
for (i=0; i<dr.FieldCount; ++i)
{

Console.Write(string.format("{0}={1}\n",dr.GetName(i),dr.GetValue(i));
}
}
dr.Close();

this code will work with any datareader the function creates
(SQL,OBDC,Oracle,etc). any Implementation of IDataReader must also implement
the IDataRecord inteface.

-- bruce (sqlwork.com)



"Edward Diener" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
| I would have expected an IDataReader to be able to return an IDataRecord
| from some interface function for the current row, to allow one to fetch
the
| row and its values generically. But I did not find such functionality. Did
I
| miss it ? Why is IDataReader not designed as generically as the other ADO
| .NET interfaces ?
|
|


 
Reply With Quote
 
Edward Diener
Guest
Posts: n/a
 
      11th Dec 2004
bruce barker wrote:
> it is generic. that what the IDataReader and IDataRecord intefaces
> are for.
>
> IDataReader dr = createADataReader();
> while (dr.read)
> {
> for (i=0; i<dr.FieldCount; ++i)
> {
>
> Console.Write(string.format("{0}={1}\n",dr.GetName(i),dr.GetValue(i));


It is my mistake. I know see that IDataReader implements IDataRecord. You
are correct that it is generic and my missing the fact that it implements
IDataRecord caused me to miss it.

> }
> }
> dr.Close();
>
> this code will work with any datareader the function creates
> (SQL,OBDC,Oracle,etc). any Implementation of IDataReader must also
> implement the IDataRecord inteface.


Yes, you have said exactly what I missed here. I was looking under the list
of IDataReader members in MSDN
(http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfsystemdataidatareadermemberstopic.asp) and only saw the ones which are
directly part of IDataReader. I noticed that for .NET classes, when one is
viewing all members, that both those which are public and protected in the
particular class and those which are public and protected in base classes
are listed. Evidently this is not the case for .NET interfaces in the MSDN
documentation, where only those which are in the particular interface are
listed and not those in base interfaces, and that is what confused me more
than anything. Because of that I had not taken a good look at the line which
shows the interface declaration itself, which lists the implemented
interfaces. Thanks for the reply !

>
> -- bruce (sqlwork.com)
>
>
>
> "Edward Diener" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I would have expected an IDataReader to be able to return an
>> IDataRecord from some interface function for the current row, to
>> allow one to fetch the row and its values generically. But I did not
>> find such functionality. Did I miss it ? Why is IDataReader not
>> designed as generically as the other ADO .NET interfaces ?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to process datareader nulls coming from datareader? JB Microsoft C# .NET 4 3rd Nov 2008 01:56 AM
Generic class which takes command string and returns datareader? =?Utf-8?B?UGV0ZXI=?= Microsoft VB .NET 7 28th Aug 2007 11:02 PM
Generic class derived from NameObjectCollectionBase and generic constraints Gabriel Lozano-Morán Microsoft Dot NET Framework 1 10th Dec 2005 12:11 PM
how do i apply an Axis design or radial design from design templa. =?Utf-8?B?bmFkaWE=?= Microsoft Powerpoint 1 3rd Apr 2005 02:21 AM
DotNet 2.0: Is a generic of a subclass a subclass of the generic of its base? Richard Corfield Microsoft Dot NET Framework 5 9th Dec 2004 02:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:53 PM.