Repository navigation
command.SingleResult().Map<T>(): the opt-out reads as behavior, then shape - #127
Merged
Merged
Conversation
…shape SingleResult() on an IExecuteReader or an IDbCommand returns a view whose Map overloads set the single-result flag, so it is exactly command.Map<T>().SingleResult(). The after-Map form still works. 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>
…d; restore the lambda's return 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
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: the SingleResult wording in mapping.md and the MappedQuery remarks keep master's text with this branch's First and Single additions; whats-new keeps both sets of bullets. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
command.SingleResult().Map<T>(): the opt-out reads as behavior, then shape.What
SingleResult()is now an extension onIExecuteReader(expressive commands) and onIDbCommand(raw commands), usable beforeMap.x.SingleResult().Map<T>()is exactlyx.Map<T>().SingleResult(), for every terminal, sync and async. The after-Mapform still works.SingleResult()is the one explicit opt-out of the library's read-through: the query reads the first result set and stops, so a failure in a later statement is not seen. That behavior and every default are unchanged. It is not onIDataReaderorDataTable, which are single-result already.SingleResult(this IExecuteReader)andSingleResult(this IDbCommand). No new public type: they return an internal wrapper that carries the flag.Mapunwraps it and runs against the ORIGINAL command with the query's existing single-result flag, so nothing on theMappath executes through the wrapper, and the caller's command is never changed.CommandBehavior.SingleResultto each reader it opens. Disposing that view disposes the command (documented).Notes for review
Mapform allocates one small wrapper object per query; the after-Mapform allocates nothing.IExecuteReaderandIDbCommandgets CS0121 onSingleResult(), as it already does onMap.Docs
SingleResultremarks and the multiple-result-sets text in mapping.md now show the before-Mapform first and mention that the after-Mapform works; whats-new-11.md has an entry.Tests
ToList,ToArray,ToImmutableArray,FirstOrDefault,SingleOrDefault,ToDictionary,ToHashSet,Read,Skip,Take,Skip+Take,Take+FirstOrDefault), sync and async, for an expressive command, aDbCommandand a plainIDbCommand; a later-set failure is thrown without the opt-out and not with it (text and stored-procedure commands); the fiveMapoverloads bind andSkip/Takekeep the flag; the after-Mapform alone and combined; the command is not mutated; null throws; both tokens cancel; compile-only binding forExpressiveSqlCommandfrom both SQL Server packages,ExpressiveCommand,ExpressiveDbCommand,SqlCommand,DbCommandandIDbCommand.Checks
🤖 Generated with Claude Code