Table of Contents

Class InMemoryEnumerator<TResult, TEntity>

Namespace
NextORM.Core
Assembly
nextorm.core.dll

Enumerates the results of an in-memory query, mapping each TEntity source row to a TResult projection. Supports both asynchronous and synchronous consumption (the data is already in memory) and, when DISTINCT was requested, de-duplicates projected values as they are produced.

public sealed class InMemoryEnumerator<TResult, TEntity> : IAsyncEnumerator<TResult>, IAsyncDisposable, IEnumerator<TResult>, IEnumerator, IDisposable, IEnumerable<TResult>, IEnumerable

Type Parameters

TResult

The projected element type.

TEntity

The source element type.

Inheritance
InMemoryEnumerator<TResult, TEntity>
Implements
IEnumerator<TResult>
IEnumerable<TResult>
Inherited Members
Extension Methods

Constructors

InMemoryEnumerator(InMemoryCompiledQuery<TResult, TEntity>, CancellationToken)

Initializes an enumerator over the given compiled query.

public InMemoryEnumerator(InMemoryCompiledQuery<TResult, TEntity> cmd, CancellationToken cancellationToken)

Parameters

cmd InMemoryCompiledQuery<TResult, TEntity>

The compiled in-memory query, supplying the projection and predicate.

cancellationToken CancellationToken

Token checked before each asynchronous move; once cancelled, enumeration ends.

InMemoryEnumerator(InMemoryCompiledQuery<TResult, TEntity>, CancellationToken, bool)

Initializes an enumerator over the given compiled query, optionally de-duplicating the projection.

public InMemoryEnumerator(InMemoryCompiledQuery<TResult, TEntity> cmd, CancellationToken cancellationToken, bool distinct)

Parameters

cmd InMemoryCompiledQuery<TResult, TEntity>

The compiled in-memory query, supplying the projection and predicate.

cancellationToken CancellationToken

Token checked before each asynchronous move; once cancelled, enumeration ends.

distinct bool

When true, projected values are de-duplicated as they are produced, matching SELECT DISTINCT.

Properties

Current

Gets the projected value for the current source row. Reading it before the first successful MoveNext() or after enumeration has finished is undefined.

public TResult Current { get; }

Property Value

TResult

Methods

Dispose()

Disposes the fallback source enumerator (created for arbitrary IEnumerable<T> sources) so streaming sources are not leaked. Safe to call more than once.

public void Dispose()

DisposeAsync()

Releases the underlying source enumerator. Equivalent to Dispose(); provided for IAsyncEnumerator<T> consumers.

public ValueTask DisposeAsync()

Returns

ValueTask

A completed value task.

GetEnumerator()

Returns this instance as the synchronous enumerator over the projected results.

public IEnumerator<TResult> GetEnumerator()

Returns

IEnumerator<TResult>

This enumerator.

Init(IEnumerable<TEntity>, object[]?)

Binds the source sequence and parameter values to enumerate. Called once before enumeration by the in-memory executor; data is dispatched to fast paths for List<TEntity> and TEntity[], falling back to a generic enumerator otherwise.

public void Init(IEnumerable<TEntity> data, object[]? @params)

Parameters

data IEnumerable<TEntity>

The source rows to enumerate.

params object[]

Positional parameter values consumed by a parameterised predicate, if any.

MoveNext()

Advances to the next row matching the predicate and, when DISTINCT was requested, skips already-seen projections.

public bool MoveNext()

Returns

bool

true when a row was found; otherwise false.

MoveNextAsync()

Asynchronously advances to the next matching row. Because the data is already in memory the work is synchronous; the returned task is already completed.

public ValueTask<bool> MoveNextAsync()

Returns

ValueTask<bool>

true when a row was found; otherwise false.

Reset()

Does nothing. Re-running the source would require a fresh Init(IEnumerable<TEntity>, object[]?), so the enumerator is re-created rather than reset.

public void Reset()