Repository navigation
Source: remove IMappedQuery<T>.Select and ProjectedQuery; RowMap<T>.From is the replacement - #152
Merged
Merged
Conversation
…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
marked this pull request as ready for review
November 16, 2026 01:41
…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>
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.
What this changes
Removes
Selectfrom the typed command views (IMappedQuery<T>and the four command-level views, through the one extension) and the internalProjectedQuerybehind it. The reader-levelIDataReader.Select/SelectAsyncstay.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
RowMaporMap(Func<IDataRecord, T>), for exampleRowMap<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 onToChannelReader(), 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 intoPublicAPI.Shipped.txt, so there is no*REMOVED*line and the analyzer reports nothing. The rc.5 item inwhats-new-11.mdis rewritten as a removal note with the migration route.MappedQuery.cs,MappedViews.cs,ExpressiveDbCommandBase.csandRowReader.csare untouched, so the internal row-source seam andMap<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
Selecttest 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 hasSelect, that the reader-levelSelectstill compiles, and the replacement forms.Found, not fixed here. A test of the foreign-
IMappedQuery<T>fallback (the terminals' generic path) showed thatToListAsyncandFirstOrDefaultAsyncon 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.mdsection is replaced by one sentence; the docs-site sample and the samples program use the map forms.Benchmarks. The 11
Selectuses 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/V4bMap(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--verifypasses (8,524 checks); no benchmark was run.Checks
lazyIdschecks use the async terminals. DocFX builds with 0 warnings.🤖 Generated with Claude Code