Table of Contents

Class ResultSetEnumerator<TResult>

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Enumerates the rows of a prepared database command. The data reader is created lazily on the first move, using the connection supplied by IConnectionManager; rows are materialized by the compiled query's map delegate inside MoveNext/MoveNextAsync, leaving Current a plain field read.

public sealed class ResultSetEnumerator<TResult> : IAsyncEnumerator<TResult>, IAsyncDisposable, IEnumerator<TResult>, IEnumerator, IDisposable

Type Parameters

TResult

The projected element type.

Inheritance
ResultSetEnumerator<TResult>
Implements
IEnumerator<TResult>
Inherited Members
Extension Methods

Constructors

ResultSetEnumerator(DbPreparedQueryCommand<TResult>, ObjectPool<StringBuilder>?)

Initializes an enumerator for the given compiled database query.

public ResultSetEnumerator(DbPreparedQueryCommand<TResult> compiledQuery, ObjectPool<StringBuilder>? sbPool = null)

Parameters

compiledQuery DbPreparedQueryCommand<TResult>

The compiled query supplying the command text, behavior and row mapper.

sbPool ObjectPool<StringBuilder>

Pool used to build the sensitive-data log message; defaults to StringBuilderPool.Shared when null.

Properties

Current

Gets the row materialized by the most recent successful MoveNext() or MoveNextAsync().

public TResult Current { get; }

Property Value

TResult

Methods

Dispose()

Releases the enumerator by resetting it, then suppresses finalization.

public void Dispose()

DisposeAsync()

Asynchronously disposes the active data reader, if any, releases an execution-owned command and releases this execution's per-connection lease. The underlying connection is owned by the context and is not closed here; the lease is released even when the reader disposal throws.

public ValueTask DisposeAsync()

Returns

ValueTask

A value task completing when the reader, command and lease have been released.

InitReader(object[]?)

Opens the connection and executes the command synchronously, creating the data reader. Does nothing when a reader already exists.

public void InitReader(object[]? @params)

Parameters

params object[]

Positional parameter values, in the order the SQL references them.

Exceptions

InvalidOperationException

No connection or connection manager has been assigned.

InitReaderAsync(object[]?, CancellationToken)

Asynchronously opens the connection and executes the command, creating the data reader. Does nothing when a reader already exists.

public Task InitReaderAsync(object[]? @params, CancellationToken cancellationToken)

Parameters

params object[]

Positional parameter values, in the order the SQL references them.

cancellationToken CancellationToken

Token used to cancel opening and execution.

Returns

Task

A task completing when the reader has been created.

Exceptions

InvalidOperationException

No connection or connection manager has been assigned.

MoveNext()

Synchronously advances to the next row, opening the reader and executing the command on the first call.

public bool MoveNext()

Returns

bool

true when a row was read; otherwise false.

MoveNextAsync()

Asynchronously advances to the next row, opening the reader and executing the command on the first call. When the provider completes ReadAsync synchronously (the common buffered case) the row is read without crossing an await.

public ValueTask<bool> MoveNextAsync()

Returns

ValueTask<bool>

true when a row was read; otherwise false.

Reset()

Disposes and clears the active data reader so the enumerator can start over. The connection is only dropped, not disposed, because it is owned by the context.

public void Reset()