Table of Contents

Class SimpleTypeParser<T>

Namespace
Rinku.Mapping.Parsers.Defaults
Assembly
Rinku.dll

The parser for a plain row type, one T read straight from the current row by a delegate. The common case behind a single object, a list element, or a scalar, with no row of its own to look past.

public sealed class SimpleTypeParser<T> : BaseTypeParser<T>, ISimpleParser<T>, ISimpleParser, IStepParser<T>, ITypeParser<T>, ITypeParser, IDisposable

Type Parameters

T
Inheritance
SimpleTypeParser<T>
Implements
Inherited Members
Extension Methods

Constructors

SimpleTypeParser(CommandBehavior, Func<DbDataReader, T>, ColumnInfo[])

Creates a parser that requires the supplied schema shape.

public SimpleTypeParser(CommandBehavior behavior, Func<DbDataReader, T> parser, ColumnInfo[] schema)

Parameters

behavior CommandBehavior
parser Func<DbDataReader, T>
schema ColumnInfo[]

Fields

Parser

The delegate that reads one row into a T.

public readonly Func<DbDataReader, T> Parser

Field Value

Func<DbDataReader, T>

Properties

Behavior

The reader behavior this parser wants, passed to ExecuteReader(CommandBehavior).

public override CommandBehavior Behavior { get; }

Property Value

CommandBehavior

Remarks

RowParser

Gets the delegate that reads the current row without advancing the reader.

public Func<DbDataReader, T> RowParser { get; }

Property Value

Func<DbDataReader, T>

Methods

CanParse(ColumnInfo[])

Whether this parser can read a result carrying schema.

public override bool CanParse(ColumnInfo[] schema)

Parameters

schema ColumnInfo[]

Returns

bool

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 T Default()

Returns

T

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public override void Dispose()

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, T Result) Parse(DbDataReader reader)

Parameters

reader DbDataReader

Returns

(bool CanContinue, T 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, T Result)> ParseAsync(DbDataReader reader, CancellationToken ct = default)

Parameters

reader DbDataReader
ct CancellationToken

Returns

ValueTask<(bool CanContinue, T Result)>