Skip to content

rc.4: Map<T>() on a reader or a raw command (MappedReader<T>, MappedCommand<T>) - #117

Merged
electricessence merged 17 commits into
masterfrom
feat/mapped-views
Nov 11, 2026
Merged

electricessence merged 17 commits into
masterfrom
feat/mapped-views

Conversation

@electricessence

@electricessence electricessence commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Map<T>() on a reader or a raw command, for 11.0.0-rc.4 (API shape). #111 is merged and master is merged in.

What

  • reader.Map<T>() returns MappedReader<T>, and command.Map<T>() returns MappedCommand<T>.
  • Both are readonly record structs that implement IMappedQuery<T>, with exactly the members MappedQuery<T> has: every terminal in its sync and async form (ValueTask, token last), Read/ReadAsync, and Skip/Take, which return the existing MappedQueryWithSkip<T>/MappedQueryWithTake<T>. Nothing new.
  • SingleResult() is on MappedCommand<T> only.
  • 5 Map<T> overloads each on IDataReader and IDbCommand, mirroring the IExecuteReader ones (same parameter lists, OverloadResolutionPriority values and guards).

Ownership

  • Reader view: the caller owns the reader. It reads the current result set from the current position and never opens, closes or disposes the reader, and never calls NextResult. On a reader view, SingleResult() reached through Skip/Take is a no-op.
  • Command view: the same as an expressive command's MappedQuery<T>. It opens the connection only if it is closed and closes (not disposes) only what it opened; it reads through the later result sets to surface late failures unless SingleResult() was called; async terminals open and execute asynchronously on a DbCommand.

Behavior changes in this PR

  • A null RowMap<T> passed to Map<T>(map) now maps by default, exactly like Map<T>(), at all three levels. It used to throw ArgumentNullException on IExecuteReader. Noted in whats-new-11.md.
  • A default struct of the whole family (MappedQuery<T>, the two staging structs and the two views) now throws InvalidOperationException saying it was not created by Map<T>(), instead of a NullReferenceException.
  • A type of your own that implements both IExecuteReader and IDbCommand (or IDataReader) gets an ambiguous Map call (CS0121); cast to pick a level.

Docs

  • The Map<T> remarks now say how columns match by default: exactly, then ignoring case, then ignoring case and underscores (author_id feeds AuthorId), with the resolved layout cached per result-set layout.
  • mapping.md has a section on mapping a reader or command you already have; whats-new-11.md lists the changes; two new compiled samples are checked in Program.cs.

Checks

  • Release and Debug builds: 0 warnings, 0 errors. Tests: 9666 of 9666 pass in both. Samples: 102 of 102 checks pass. Style and analyzers: 0 findings. DocFX: 0 warnings.

Since the review

🤖 Generated with Claude Code

electricessence and others added 15 commits November 10, 2026 06:51
…async terminals that take the type

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…s of a command and their binding

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ne, => on its own line, doc comments wrapped at natural breaks

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ader or command

A null map, an empty pair list and a default struct behave as documented.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Base automatically changed from feat/command-terminals to master November 11, 2026 01:40
electricessence and others added 2 commits November 10, 2026 17:53
…en gives a cancelled task, document Read() and the CS0121 ambiguity

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@electricessence
electricessence merged commit 4411d88 into master Nov 11, 2026
2 checks passed
@electricessence
electricessence deleted the feat/mapped-views branch November 11, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant