The DataReader

The DataReader provides a forward-only, read-only stream of data from the data store. The DataReader is best used when either there are many records in the result set and pulling them all in at once would use too much memory, or when you want to iterate through the records to work with the data returned. As a stream of records, the DataReader helps manage memory allocation. Rather than all of the records in the result set being returned at once and using up a chunk of memory on the server, the DataReader streams in one record at a time.

You've seen how to execute a command against a data store, and in the previous listings, the results weren't too big. But imagine if your Managed Command returned a result set with over 100,000 ...

Get Programming Data-Driven Web Applications with ASP.NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.