Class BaseEnumerableTypeParser<T>
The base for the streamed shape, IEnumerable<T>, it yields rows as you enumerate rather than buffering them, keeping memory flat on large results. It holds the reader open while you iterate and disposes it when enumeration ends.
public abstract class BaseEnumerableTypeParser<T> : IReaderHoldingParser<IEnumerable<T>>, ITypeParser<IEnumerable<T>>, ITypeParser, IDisposable
Type Parameters
T
- Inheritance
-
BaseEnumerableTypeParser<T>
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
BaseEnumerableTypeParser(Func<DbDataReader, T>?)
The base for the streamed shape, IEnumerable<T>, it yields rows as you enumerate rather than buffering them, keeping memory flat on large results. It holds the reader open while you iterate and disposes it when enumeration ends.
protected BaseEnumerableTypeParser(Func<DbDataReader, T>? rowParser = null)
Parameters
rowParserFunc<DbDataReader, T>
Properties
Behavior
The reader behavior this parser wants, passed to ExecuteReader(CommandBehavior).
public abstract CommandBehavior Behavior { get; }
Property Value
Remarks
Often SequentialAccess or SingleResult.
Methods
CanParse(ColumnInfo[])
Whether this parser can read a result carrying schema.
public abstract bool CanParse(ColumnInfo[] schema)
Parameters
schemaColumnInfo[]
Returns
Remarks
A parser may accept several schemas. A parser that reads names and types at each call may accept every schema.
Default()
The value to return when the result has no row, an empty collection or optional, for instance.
public IEnumerable<T> Default()
Returns
- IEnumerable<T>
Parse(DbDataReader)
The enumerable is lazy, rows are read while it is enumerated,
so CanContinue cannot be known up front and is always false
public (bool CanContinue, IEnumerable<T> Result) Parse(DbDataReader reader)
Parameters
readerDbDataReader
Returns
- (bool CanContinue, IEnumerable<T> Result)
ParseAsync(DbDataReader, CancellationToken)
The enumerable is lazy, rows are read while it is enumerated,
so CanContinue cannot be known up front and is always false
public ValueTask<(bool CanContinue, IEnumerable<T> Result)> ParseAsync(DbDataReader reader, CancellationToken ct = default)
Parameters
readerDbDataReaderctCancellationToken
Returns
- ValueTask<(bool CanContinue, IEnumerable<T> Result)>
ParseOne(DbDataReader)
Used to parse a single item. Reports whether the reader is left on an untreated row
protected abstract (bool CanContinue, T Result) ParseOne(DbDataReader reader)
Parameters
readerDbDataReader
Returns
- (bool CanContinue, T Result)
ParseThen<TDone>(DbDataReader, TDone)
Reads from a reader the caller owns, running onDone once the rows are walked out
or the walk is left early.
public IEnumerable<T> ParseThen<TDone>(DbDataReader reader, TDone onDone) where TDone : IReaderDone
Parameters
readerDbDataReaderonDoneTDone
Returns
- IEnumerable<T>
Type Parameters
TDone
Query(DbCommand, ICache, bool)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, also letting cache learn from the executed command.
public IEnumerable<T> Query(DbCommand command, ICache cache, bool disposeCommand = false)
Parameters
Returns
- IEnumerable<T>
Query(DbCommand, bool)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public IEnumerable<T> Query(DbCommand command, bool disposeCommand = false)
Parameters
Returns
- IEnumerable<T>
Query(IDbCommand, ICache, bool)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, also letting cache learn from the executed command.
public IEnumerable<T> Query(IDbCommand command, ICache cache, bool disposeCommand = false)
Parameters
commandIDbCommandcacheICachedisposeCommandbool
Returns
- IEnumerable<T>
Query(IDbCommand, bool)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public IEnumerable<T> Query(IDbCommand command, bool disposeCommand = false)
Parameters
commandIDbCommanddisposeCommandbool
Returns
- IEnumerable<T>
QueryAsync(DbCommand, ICache, bool, CancellationToken)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public Task<IEnumerable<T>> QueryAsync(DbCommand command, ICache cache, bool disposeCommand = false, CancellationToken ct = default)
Parameters
commandDbCommandcacheICachedisposeCommandboolctCancellationToken
Returns
- Task<IEnumerable<T>>
Remarks
Awaiting opens the reader and reads the first row asynchronously.
Enumeration reads the remaining rows synchronously and closes the reader when it ends.
Use StreamQueryAsync to read every row asynchronously.
QueryAsync(DbCommand, bool, CancellationToken)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public Task<IEnumerable<T>> QueryAsync(DbCommand command, bool disposeCommand = false, CancellationToken ct = default)
Parameters
commandDbCommanddisposeCommandboolctCancellationToken
Returns
- Task<IEnumerable<T>>
Remarks
Awaiting opens the reader and reads the first row asynchronously.
Enumeration reads the remaining rows synchronously and closes the reader when it ends.
Use StreamQueryAsync to read every row asynchronously.
QueryAsync(IDbCommand, ICache, bool, CancellationToken)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public Task<IEnumerable<T>> QueryAsync(IDbCommand command, ICache cache, bool disposeCommand = false, CancellationToken ct = default)
Parameters
commandIDbCommandcacheICachedisposeCommandboolctCancellationToken
Returns
- Task<IEnumerable<T>>
Remarks
Awaiting opens the reader and reads the first row asynchronously.
Enumeration reads the remaining rows synchronously and closes the reader when it ends.
Use StreamQueryAsync to read every row asynchronously.
QueryAsync(IDbCommand, bool, CancellationToken)
Runs command and reads its result as System.Collections.Generic.IEnumerable{`0}, disposing the command afterward when disposeCommand is set.
public Task<IEnumerable<T>> QueryAsync(IDbCommand command, bool disposeCommand = false, CancellationToken ct = default)
Parameters
commandIDbCommanddisposeCommandboolctCancellationToken
Returns
- Task<IEnumerable<T>>
Remarks
Awaiting opens the reader and reads the first row asynchronously.
Enumeration reads the remaining rows synchronously and closes the reader when it ends.
Use StreamQueryAsync to read every row asynchronously.