Implementation of SqlDataReader and ExecuteReader

  • Thread starter Thread starter codefixer
  • Start date Start date
C

codefixer

Hello:

I am trying to understand the implementation of SqlDataReader and
ExecuteReader. I know how to use them in C#. But my real interest is to
know how those APIs themselves are written.

Say my Table has the following columns
Phone #(xxx-xxx-xxxx), Name(String), Month(1-12),
Balance(0.00-999,999.99)

Assume I have a Recordset pointing to rows of data in the format above.
My intention is to understand how are the APIs themselves implemented.
Do they create a class on demand with all the necessary
datatypes(because they know what datatypes their compiler supports
before compile time) and then go on reading from table.

Alternatively can everyting be read as a "string" ir-respective of the
format and the CASTED to respective format ?

I am not sure these are my guesses, can someone shed some light ?

Thanks.
 
i think, it retrieves column metadata from the dbms, and map it to internal
..net datatypes. for example char, nchar, varchar, nvarchar is represented in
..net as string, while datetime, smalldatetime represented as DateTime. i
think it retrieves column type information of the query result from
database. if you investigate datareader-dataparemter.Value objects from
command window, you can see they have a property something like "Underlying
System Type".
 
Back
Top