Table of Contents

Class BatchResult

Namespace
NextORM.Core
Assembly
nextorm.core.dll

The eagerly materialised result sets of a batch built with AddQuery<TResult>(QueryCommand<TResult>) and executed with Execute() or ExecuteAsync(CancellationToken). Every set is fully buffered in memory, so the instance owns no reader or connection and is not disposable. The result object itself enumerates its result sets: foreach (var set in result) or await foreach (var set in result) yields a ResultSet cursor per set. The legacy Read<TResult>() path reads sets positionally.

public sealed class BatchResult : IEnumerable<ResultSet>, IEnumerable, IAsyncEnumerable<ResultSet>
Inheritance
BatchResult
Implements
Inherited Members
Extension Methods

Properties

RecordsAffected

The number of rows the batch's statements affected, as reported by the driver in one total, or -1 when the batch has no affected-row metadata. The value is captured when the batch reader is released and is part of the eagerly materialised result, so this instance owns no reader: it never touches a database, is safe to read at any time, and is not derived from ResultSetCount or from the number of materialised rows.

public int RecordsAffected { get; }

Property Value

int

ResultSetCount

The number of result sets the batch produced, in the order the queries were added.

public int ResultSetCount { get; }

Property Value

int

Methods

GetAsyncEnumerator(CancellationToken)

Returns an async enumerator over the buffered result sets of the batch. See GetEnumerator(); the batch is eager, so this never touches a reader.

public IAsyncEnumerator<ResultSet> GetAsyncEnumerator(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the traversal between sets.

Returns

IAsyncEnumerator<ResultSet>

A one-shot, forward-only async sequence of result-set cursors; empty when the batch has none.

Exceptions

InvalidOperationException

The result was already enumerated or read with Read<TResult>().

GetEnumerator()

Returns an enumerator over the buffered result sets of the batch in the order the queries were added, yielding a ResultSet cursor per set. Each set can be consumed once with Read<T>() or ReadAsync<T>(CancellationToken).

public IEnumerator<ResultSet> GetEnumerator()

Returns

IEnumerator<ResultSet>

A one-shot, forward-only sequence of result-set cursors; empty when the batch has none.

Exceptions

InvalidOperationException

The result was already enumerated or read with Read<TResult>().

Read<TResult>()

Returns the next result set, in the order the result queries were added. Each set may be read once; the set's projected row type must match TResult.

public IReadOnlyList<TResult> Read<TResult>()

Returns

IReadOnlyList<TResult>

The rows of the next result set.

Type Parameters

TResult

The projected row type of the next result set.

Remarks

The result sets are forward-only: every call returns the next set in order and there is exactly one call per set (the first call returns the first set, the second call the second set, and so on). A call with the wrong TResult throws without consuming the set, so it can be retried with the matching type; reading past the last set throws. Use ResultSetCount to know how many sets exist. This positional path cannot be mixed with enumerating the result object.

Exceptions

InvalidOperationException

There is no further result set, the next set's projected type is not TResult, or the result was enumerated.