-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
DbDataReader currently implements non-generic IEnumerable only, with no default implement (abstract). Implementations typically return a DbEnumerator (source) instance, which exposes DbDataRecords as the elements.
The problems with the current situation are:
- The lack of a generic IEnumerable implementation
- The lack of async enumeration support
- DbDataRecord lacks an async field access API (
GetFieldValue<T>, like on DbDataReader)- It should be noted that DbDataRecord itself also lacks async access APIs. This probably makes sense, as it represents a record/row that has been fully loaded into memory, and no actual I/O is meant to take place when its columns are accessed.
- This also allows older DbDataRecord instances to be retained after new ones have been read via the same DbDataReader.
- If the user is interested in streaming column access, they can use DbDataReader directly, rather than going through IEnumerable/IAsyncEnumerable.
In an ideal world, we'd make DbDataReader implement IEnumerable<DbDataRecord> and IAsyncEnumerable<DbDataRecord>; the default implementations for these would return an enumerator implementation from System.Data - either a DbEnumerator retro-fitted to work with DbDataReader and its async APIs (DbEnumerator currently works with IDataReader), or a new implementation.
Leaving this issue open for now, to gather more user feedback, as we haven't seen much interest in this (but see previous discussion in #98890).