Skip to content

Source: remove IMappedQuery<T>.Select and ProjectedQuery; RowMap<T>.From is the replacement - #152

Merged
electricessence merged 6 commits into
masterfrom
feat/a2-remove-select
Nov 16, 2026
Merged

electricessence merged 6 commits into
masterfrom
feat/a2-remove-select

Conversation

@electricessence

@electricessence electricessence commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What this changes

Removes Select from the typed command views (IMappedQuery<T> and the four command-level views, through the one extension) and the internal ProjectedQuery behind it. The reader-level IDataReader.Select / SelectAsync stay.

Why. The owner: "The problem with leaving Select, is it's a footgun that allows the consumer to do stupid or sub-optimal stuff." A second projection step after the map hides work in the read loop; the row should be shaped once, by the map.

Where to go instead (the migration line):

  • To shape the row itself: a RowMap or Map(Func<IDataRecord, T>), for example RowMap<T>.From(factory, pairs).

  • For a projection or post-processing step after the map: the owner's suggestion is .Map<T>().ToChannelReader() plus Open.ChannelExtensions .Transform(...): the reader closes fast and the projection runs off the read path. That depends on ToChannelReader(), which lands in a later change; this PR names it in the migration line and writes no code for it.

  • Public API: exactly one line deleted from the unshipped list. The rc.5 notes listed Select, but the rc.5 release never moved its line into PublicAPI.Shipped.txt, so there is no *REMOVED* line and the analyzer reports nothing. The rc.5 item in whats-new-11.md is rewritten as a removal note with the migration route. MappedQuery.cs, MappedViews.cs, ExpressiveDbCommandBase.cs and RowReader.cs are untouched, so the internal row-source seam and Map<T>()'s final call are unchanged.

  • What a consumer sees: a compile error (CS1929, or CS0019 when the lambda does arithmetic on its parameter) at each .Select(...) on a view.

  • Tests: the old Select test file (1,221 lines) is deleted; the read-through, single-result, release, cancellation and foreign-implementer behaviours it also exercised are pinned on the views by their own test files. A new small file asserts by reflection that no view has Select, that the reader-level Select still compiles, and the replacement forms.

  • Found, not fixed here. A test of the foreign-IMappedQuery<T> fallback (the terminals' generic path) showed that ToListAsync and FirstOrDefaultAsync on a foreign implementation resume on the caller's context through the in-box async LINQ on net10 and net11. That is the behaviour on master today, not something this change introduced, so the test is not in this PR; it is fixed separately with its own tests.

  • Docs and samples: the mapping.md section is replaced by one sentence; the docs-site sample and the samples program use the map forms.

  • Benchmarks. The 11 Select uses are rewritten in this change to the migration target, nothing deleted and the variant names and order unchanged: V3, V3Async and V3s use a cached factory map, V4a/V4b Map(record => f(selector(record))), V6c a cached map, and the real-provider V3 (documented as the consumer's pattern) now measures what the consumer will run after this change. The benchmark project builds in Release with warnings as errors and its synthetic --verify passes (8,524 checks); no benchmark was run.

Checks

  • Release build of the whole solution with 0 warnings on every Core target framework; the public-API analyzer reports nothing.
  • The full test gate (Core tests on net10.0 and net11.0, the legacy-compiler tests, the samples) and a Visual Studio MSBuild of the solution are green; leak scan clean.
  • The samples program runs: "All 125 sample checks passed." Its lazyIds checks use the async terminals. DocFX builds with 0 warnings.
  • After merging master (which now has the pair-map removal and the foreign-query context fix), the Select-removal tests and the foreign-query context tests pass 143 of 143 on net10.0 and net11.0.

🤖 Generated with Claude Code

electricessence and others added 4 commits November 15, 2026 15:52
…rom is the replacement

Select on a mapped query was a footgun: it let a consumer put a second per-row object and caller code inside the open read, and an early-stopping terminal reached through it skipped the read-through. A mapped view is shaped by Map(RowMap<TResult>.From(factory)) (one object per row), or projected after a terminal. The reader-level IDataReader.Select/SelectAsync stay, and so do the IMappedTerminals<T> fast path and the LINQ fallback for foreign IMappedQuery<T> implementers.

The unshipped PublicAPI line is deleted (no REMOVED line). The Select tests are replaced by a small test file (reflection check that no view has a Select, the reader-level Select still compiles, the replacement forms, and the fallback never resuming on the caller's context). The docs section and the two samples move to the factory map, and the Benchmarks variants built on Select (V3, V4a, V4b, V6c, V3s) now measure the replacement.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…oval

The test asserted that a foreign IMappedQuery<T> never resumes on the caller's context. It fails on master as well: the fallback terminals use the in-box async LINQ, whose own state machine does not use ConfigureAwait(false). That is a separate defect, recorded in the A2 notes, not part of removing Select.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The item linked to a mapping.md section that is gone (an invalid bookmark in the docs build). It now says Select is removed and points to the factory map.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
electricessence and others added 2 commits November 15, 2026 17:43
…the factory-map include

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The one conflict was in MappedQueryExtensions.cs: the Select method this branch deletes sat next to the new foreign-query helpers from master. Select stays deleted and the helpers are kept.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 4df881b into master Nov 16, 2026
7 checks passed
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