A subclass that hides AddParameters and re-implements the interface - the
DynamicParameterWithIntTVP pattern from this very test suite - was skipped
by the direct call, which binds statically to the protected base method.
Routing through the interface uses the runtime type's interface map, so
the subclass version runs, matching what vanilla execution does.
The full bag protocol (per-parameter DbType/direction/size, templates,
literal replacement, RemoveUnused) already lives in AddParameters(command,
identity), but the identity requirement makes it uncallable from outside:
Identity's constructor is internal, and identity.Sql is consumed on the
first line. This overload builds the identity from the command's own text
and type, which is what identity.Sql is in practice - letting external
tooling (for example build-time code generators, aka Dapper.AOT) apply a
bag without reimplementing the protocol.
Test covers the bag+literal composition against a closed connection (no
database needed).
* Add Settings.PreferTypeHandlersForEnums opt-in flag
When enabled, Dapper checks for a registered TypeHandler for enum types
before falling back to the default integer boxing behavior. This allows
custom enum serialization (e.g. storing enums as strings via TypeHandlers)
to work on both reads and writes.
Patched locations:
- LookupDbType: return DbType.Object with handler when flag is on
- CreateParamInfoGenerator: skip integer boxing when handler exists
- GetSimpleValueDeserializer: route to TypeHandler before Enum.ToObject
- Parse<T>: route to TypeHandler before Enum.ToObject
Default is false — zero behavior change for existing users.
* Patch IL-emitted type deserializer and add tests
- Fix 6th enum-before-handler location in GetTypeDeserializer IL emit,
preserving Nullable<T> wrapping for nullable enum properties
- Fix em-dash in comment (non-ASCII)
- Add two tests: round-trip write+read via StringEnumHandler, and
nullable enum with null value
* Update SDK version from 10.0.102 to 8.0.100
* Update global.json
we have fixed the CI glitch separately
---------
Co-authored-by: Marc Gravell <marc.gravell@gmail.com>
The IL emitted by CreateParamInfoGenerator used Callvirt to invoke
AddParameter on an unboxed struct sitting on the evaluation stack.
Callvirt expects a reference, so the CLR misinterpreted the raw struct
bytes as an object pointer, causing a fatal CLR error (0x80131506).
* see #2115
- correctness: do no use SingleRow by default; affects trailing errors
- performance: QueryUnbufferedAsync can mirror cmd?.Cancel() in finally (this is consistent with all other scenarios)
* remove settings tweak
When disposing wrapped readers, only call Dispose() on the inner reader and let it catch exceptions if appropriate.
Note: this actually happened with `Microsoft.Data.SqlClient`.
```
Microsoft.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
at void Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)
at void Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, bool callerHasConnectionLock, bool asyncClose)
at bool Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, out bool dataReady)
at bool Microsoft.Data.SqlClient.SqlDataReader.TryCloseInternal(bool closeReader)
at void Microsoft.Data.SqlClient.SqlDataReader.Close()
at void Dapper.DbWrappedReader.Dispose(bool disposing) in /_/Dapper/WrappedReader.cs:line 149
at ValueTask System.Data.Common.DbDataReader.DisposeAsync()
```
* string and byte[] : add UseGetFieldValue to prevent problems with npgsql using global deserializer
* switch to GetFieldValue<T> changes some messaging in invalid cast scenarios; if anything, new version is clearer, so: fine
* test fixes
* Add a setting to turn off Ole Db "smell check"
* Rename setting, fix logic
* Test for SupportLegacyParameterTokens
* Fix exception type
* Add release note
* 1. auto-detect stored procedures as anything without whitespace
2. we have public fields? (hangs head in shame)
* release notes
* no need to use regex
* attempt NRT makeover
- annotate NRTs on GridReader API
- add protected access to some of the GridReader internals
- switch GridReader callbacks to be more type-independent
docs
lib updates; deal with yellow warnings and test failures (SQL server certs and cancellation surfacing differently)
fix break
simplify proposed GridReader changes to protected OnBeforeGrid and OnAfterGrid[Async]
Builds: Bump library versions (#1935)
Tests: Upgrade dependencies for Dependabot (#1936)
I'll do a pass at all of these later, but getting CVE versions out of the pipe.
Resolving 4 alerts here: https://github.com/DapperLib/Dapper/security/dependabot
merge and lib updates
allow Identity to be constructed on-the-fly inside GridReader
fix build warnings
include readme
rev minor
- enable [SkipLocalsInit] everywhere
- use NET5_0_OR_GREATER
for remoting check
# Conflicts:
# Dapper/CommandDefinition.cs
# Dapper/DefaultTypeMap.cs
# Dapper/SqlMapper.Async.cs
# Dapper/SqlMapper.IDataReader.cs
# Dapper/SqlMapper.Link.cs
# Dapper/SqlMapper.cs
# Directory.Build.props
* shipped, not unshipped
* fixup SqlBuilder; use is null / is not null
* use central package management (#1949)
* Nullable test tweaks
* Nuget: let's just remove it!
* 2 test fixes from review
* fix FindExplicitConstructor
* add GetPropertySetterOrThrow
* fix NRT on FindConstructor
* DapperRow: value is object?
* use NotNullWhen
* make constructor problem more obvious
* test fixes
---------
Co-authored-by: Nick Craver <nrcraver@gmail.com>
* if we stop supporting DbDataReader, someone is going to complain; I'd
rather wrap it for now (to make the lib work), and add an analyzer
in AOT that shouts at them for using IDbConnection
also: compiler nits
* release notes
add support for fetching values via GetFieldValue<T>; this requires
DbDataReader, but in reality the reader is *always* DbDataReader;
acknowledge this, and stop pretending to use IDataReader internally
(no breaks to public API)
* context: #1716https://github.com/DapperLib/Dapper/issues/1716
- change type-map to allow nullable
- change DateTime/TimeSpan to null
- do not specify DbType for null
- semi-breaking change: swap GetDbType to SetDbType, noting that it is marked [Obsolete] and internal-use-only
- semi-breaking change: make LookupDbType return nullable (same internal-use/[Obsolete])
* add test for Npgsql 6.0.0-rc.1
* try list parameters (like arrays)
* never assign -1 (sentinel) as the .DbType
* postgres tests