|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Datareader design not genericI 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 ? Hi Edward,
If you look at classes that implement IDataReader, you'll see that they also implement IDataRecord. -- Show quoteMiha Markic [MVP C#] - RightHand .NET consulting & development SLODUG - Slovene Developer Users Group www.rthand.com "Edward Diener" <diener_no_spam_ok@ORsoftware.com> wrote in message news:ugp4RPu3EHA.1564@TK2MSFTNGP09.phx.gbl... >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 ? > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message But classes which implement IDataReader are not generic. They are specific news:%2327MRfu3EHA.2568@TK2MSFTNGP11.phx.gbl... > Hi Edward, > > If you look at classes that implement IDataReader, you'll see that they > also implement IDataRecord. 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. Show quote > > -- > Miha Markic [MVP C#] - RightHand .NET consulting & development > SLODUG - Slovene Developer Users Group > www.rthand.com > > "Edward Diener" <diener_no_spam_ok@ORsoftware.com> wrote in message > news:ugp4RPu3EHA.1564@TK2MSFTNGP09.phx.gbl... >>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 ? >> > > 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 Show quote "Edward Diener" <diener_no_spam_ok@ORsoftware.com> wrote in message news:e5sHh#u3EHA.536@TK2MSFTNGP10.phx.gbl... > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message > news:%2327MRfu3EHA.2568@TK2MSFTNGP11.phx.gbl... > > 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" <diener_no_spam_ok@ORsoftware.com> wrote in message > > news:ugp4RPu3EHA.1564@TK2MSFTNGP09.phx.gbl... > >>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 ? > >> > > > > > > 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) Show quote "Edward Diener" <diener_no_spam_ok@ORsoftware.com> wrote in message news:ugp4RPu3EHA.1564@TK2MSFTNGP09.phx.gbl... | 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 ? | | bruce barker wrote:
> it is generic. that what the IDataReader and IDataRecord intefaces It is my mistake. I know see that IDataReader implements IDataRecord. You> 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)); are correct that it is generic and my missing the fact that it implements IDataRecord caused me to miss it. > } Yes, you have said exactly what I missed here. I was looking under the list> } > 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. of IDataReader members in MSDN (http://msdn.microsoft.com/library/default.asp?url=/library/en-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 ! Show quote > > -- bruce (sqlwork.com) > > > > "Edward Diener" <diener_no_spam_ok@ORsoftware.com> wrote in message > news:ugp4RPu3EHA.1564@TK2MSFTNGP09.phx.gbl... >> 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 ? |
|||||||||||||||||||||||