Repository navigation
ExecuteScalar<T> converts the way Map<T>() does: a bigint read as int, a numeric as long - #123
Merged
Merged
Conversation
…, a numeric as long); overflow throws The exact cast threw InvalidCastException when the column type differed from T. ExecuteScalar<T>, ExecuteScalarAsync<T>, ExecuteReturn<T> and ExecuteReturnAsync<T> now use the single-value conversion Map<T>() uses: the value as is when it is already a T, NULL and no row to default, else a range-checked conversion that throws ValueMappingException on overflow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…<T>() uses, not "the general conversion" or "cannot drift apart" 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>
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>
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.
ExecuteScalar<T>andExecuteScalarAsync<T>convert the wayMap<T>()does, so a port that keeps the sameTno longer fails only on a real database.The problem
ExecuteScalar<T>cast the value exactly and threwInvalidCastExceptionwhen the column type differed fromT: abigintserial read asint, or a numeric identity read aslong. A single-valueMap<T>()converts, and so does Dapper.What changes
ExecuteScalar<T>(),ExecuteScalarAsync<T>(),ExecuteReturn<T>()andExecuteReturnAsync<T>()use the single-value conversionMap<T>()uses:Tis returned as is;DBNulland no row givedefault(T), as before;bigintintoint, a numeric intolong, anintintolong. A value out of range throwsValueMappingExceptionwith theOverflowExceptioninside, the same asMap<int>().Func<object?, T>transform overloads are unchanged. No public signature changes, soPublicAPI.Unshipped.txtis untouched.Behavior change
InvalidCastExceptionnow convert, or throwValueMappingExceptionon overflow. Noted in whats-new-11.md.Tests
Map<T>()over a typed reader (the same value, or the same failure type and message), sync and async.bigintintoint, numeric intolong,intintolong, overflow, NULL and no row, a failed conversion leaving the connection as it was found, cancellation.bigintasint; the old "failed cast" check in the samples is replaced by three checks.Checks
TokenTerminalTests.Allocation_Channel, then aLeakPipelineTestsChannel case), which are being fixed separately. Samples: 105 of 105 checks pass. Style and analyzers: 0 findings. DocFX: 0 warnings.🤖 Generated with Claude Code