Repository navigation
RowMap<T>.Convert: a converter for one column, the rest of the type still maps by name - #125
Merged
Merged
Conversation
…till maps by name Convert<TColumn, TMember>(member, [column,] convert) returns a new RowMap<T>. The converter is compiled into the row reader and reads the column with the typed getter; NULL skips it unless TColumn is Nullable<>. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…xceptions are wrapped, the member-name wording is exact Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lection expression for the row 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>
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>
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.
RowMap<T>.Convert: a converter for one column, and the rest of the type still maps by name.A column that needs a trim, a parse or a format on its way to a member no longer forces a hand-written selector, or a row type that is mapped and then copied.
What
RowMap<T>, both returning a NEW map (the original is unchanged, as a map is immutable):Convert<TColumn, TMember>(string member, Func<TColumn, TMember> convert): the converter attaches tomember; the column is the one the map already names for it, else the column the member matches by name.Convert<TColumn, TMember>(string member, string column, Func<TColumn, TMember> convert): also names the column.TColumnthe value comes from the provider's typed getter, so nothing is boxed; otherwise it is read the wayMap<int>()reads a single value (an integer converts within its range; an overflow throwsValueMappingException). The only per-row cost is the delegate.requiredandinitmembers, in the live-reader path and in the buffered path, and with every way a map is declared.Convertis called, as pairs are when a map is created: an unknown or unsettable member, a member converted twice, aTMemberthe member cannot take, a member mapped to a null column, a column another member reads, and null arguments.Please look at (design choices)
Nullable<>TColumn(int?,DateTime?) is called with null, and its result goes to the member, a non-nullable member included. A reference-typeTColumn, evenstring?, never sees NULL, because the annotation does not exist at run time on a type argument.Convert<TColumn, TMember>(member, [column,] convert)with the member by name. A lambda alone cannot inferTColumn, so a caller writesConvert<long, string>(...)or types the lambda parameter. This is documented.new RowMap<T>(map)drops converters. Documented.ValueMappingExceptionwith the original inside, like any other failure while reading a value (a database exception and a cancellation pass through). Documented.Docs and samples
RowMap<T>remarks cover the NULL rule; whats-new-11.md has an entry; a compiled sample showsorder_numread as text and a timestamp as "HH:mm". The sample adds anorderstable to the shared sample seed.Tests
TColumn; a column of another type converts and an overflow throws; constructor,requiredandinitmembers; validation atConvert; immutability of the original map; two result-set layouts; use of one map from several threads; no per-row allocation beyond the delegate; through a reader, a command and a table.Checks
🤖 Generated with Claude Code