Interface IMappedQuery<T>
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
A deferred query whose rows are mapped to T. Nothing runs until one of the terminal methods is called.
public interface IMappedQuery<T>
Type Parameters
TThe type each row is mapped to.
- Extension Methods
Remarks
The Read and ReadAsync methods are the primitive terminals: they execute the command, hand the handler a forward-only stream of mapped rows backed by the open data reader, and release the connection when the handler returns. The convenience terminals in MappedQueryExtensions (for example ToList<T>(IMappedQuery<T>) and FirstOrDefault<T>(IMappedQuery<T>)) are built on them.
Rows are read as the handler enumerates, so enumerate inside the handler and do not let the sequence escape it: the reader is disposed as soon as the handler returns. Each terminal call executes the command again.
Methods
- Read(Action<IEnumerable<T>>)
Executes the query and passes the mapped rows to
handleras they are read.
- ReadAsync(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask>, CancellationToken)
Asynchronously executes the query and passes the mapped rows to
handleras they are read.
- ReadAsync<TResult>(Func<IAsyncEnumerable<T>, CancellationToken, ValueTask<TResult>>, CancellationToken)
Asynchronously executes the query, passes the mapped rows to
handleras they are read, and returns the handler's result.
- Read<TResult>(Func<IEnumerable<T>, TResult>)
Executes the query, passes the mapped rows to
handleras they are read, and returns the handler's result.