Repository navigation
Select on IMappedQuery<T> composes a projection without running the query (query factories) - #124
Merged
Merged
Conversation
…uery The result is an IMappedQuery<TResult> built over Read and ReadAsync, so a data class can return the query and the caller picks the terminal. Nothing runs until a terminal does. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…he concrete query type for the helper Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
electricessence
added a commit
that referenced
this pull request
Nov 12, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
electricessence
added a commit
that referenced
this pull request
Nov 12, 2026
Conflicts: First/Single and Select are both added at the end of MappedQueryExtensions, so both are kept; the public-API list, the notes and the samples keep both sides. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This was referenced Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SelectonIMappedQuery<T>composes a projection without running the query, so a data class can return the query and let the caller pick the terminal.What
public static IMappedQuery<TResult> Select<T, TResult>(this IMappedQuery<T> query, Func<T, TResult> selector)is the only new public member. The type that implements it is internal.ReadandReadAsync, so every existing terminal onIMappedQuery<T>works on the result, sync and async, at every level (expressive command, raw command, reader, table). The connection ownership, the read-through of later result sets and theSingleResult()behavior of the source are unchanged.FirstOrDefault, aTake) runs it for the rows read and releases the reader; a selector that throws or a cancellation releases it too. ChainedSelectcomposes and uses one reader.SkipandTakeare not on the interface, so they apply to the source beforeSelect.Known limitations (follow-up)
IMappedQuery<T>extension form.ToArraythere uses LINQ'sToArray, not the library's pooled buffer, and an early-stopping terminal (FirstOrDefault) does not read through later result sets (the same as the interface extensions do today). Both are fixed together in a follow-up so the projection can hand its terminals to the source.Docs
Tests
Select), every terminal sync and async, selector once per row and in order, early exit with the reader released, selector throws, cancellation (before, during, command token, token handed to the handler), release of the reader, command and connection, chainedSelect, two terminals run the command twice, a default struct, null arguments, a fixed-cost allocation guard.Checks
🤖 Generated with Claude Code