Does anyone know how DbDataReaders work. We can use SqlDataReader as an example.
When you follow these
cmd.CommandText = "SELECT * FROM Customers";
var rdr = cmd.ExecuteReader();
while(rdr.Read())
{
}
Does the data reader have all the lines in memory, or does it just grab one, and then when Read is called, does it go to db and grab the next one? It seems that just to bring it to memory would be poor performance, but at the same time all of them would force it to be engaged when calling ExecuteReader.
I know that I am a consumer of the object, and it doesn’t really matter how they implement it, but I’m just curious, and I think I’ll probably spend a couple of hours in Reflector to get an idea of what it is doing, therefore thought that I would ask someone who might know this.
I'm just wondering if anyone has an idea.