Class FastOptionalTypeParser<TOpt, T>
Builds an optional value with a row delegate that does not advance the reader.
public sealed class FastOptionalTypeParser<TOpt, T> : BaseTypeParser<TOpt>, ISimpleParser<TOpt>, ISimpleParser, IStepParser<TOpt>, ITypeParser<TOpt>, ITypeParser, IDisposable where TOpt : struct, IWrapping<TOpt, T>
Type Parameters
TOptT
- Inheritance
-
BaseTypeParser<TOpt>FastOptionalTypeParser<TOpt, T>
- Implements
-
ISimpleParser<TOpt>IStepParser<TOpt>ITypeParser<TOpt>
- Inherited Members
- Extension Methods
Constructors
FastOptionalTypeParser(CommandBehavior, Func<DbDataReader, T>, ITypeParser)
Builds an optional value with a row delegate that does not advance the reader.
public FastOptionalTypeParser(CommandBehavior behavior, Func<DbDataReader, T> parser, ITypeParser schemaParser)
Parameters
behaviorCommandBehaviorparserFunc<DbDataReader, T>schemaParserITypeParser
Properties
Behavior
The reader behavior this parser wants, passed to ExecuteReader(CommandBehavior).
public override CommandBehavior Behavior { get; }
Property Value
Remarks
Often SequentialAccess or SingleResult.
RowParser
Gets the delegate that reads the current row without advancing the reader.
public Func<DbDataReader, TOpt> RowParser { get; }
Property Value
- Func<DbDataReader, TOpt>
Methods
CanParse(ColumnInfo[])
Whether this parser can read a result carrying schema.
public override 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 override TOpt Default()
Returns
- TOpt
Parse(DbDataReader)
Parses one T starting at the current row, advancing the reader as it goes.
CanContinue reports the state of the reader on return, true when it is
positioned on an untreated row, false when no row is left
public override (bool CanContinue, TOpt Result) Parse(DbDataReader reader)
Parameters
readerDbDataReader
Returns
- (bool CanContinue, TOpt Result)
ParseAsync(DbDataReader, CancellationToken)
Parses one T starting at the current row, advancing the reader as it goes.
CanContinue reports the state of the reader on return, true when it is
positioned on an untreated row, false when no row is left
public override ValueTask<(bool CanContinue, TOpt Result)> ParseAsync(DbDataReader reader, CancellationToken ct = default)
Parameters
readerDbDataReaderctCancellationToken
Returns
- ValueTask<(bool CanContinue, TOpt Result)>