Commit bb614e4
fix: correct SqlMetaData constructor selection for datetime2/datetimeoffset/time TVP columns
The previous fix for #393 used `match name, dbType with` where `name`
is the column name (e.g. "CreatedAt"), not the SQL type name. This meant
the pattern | "datetime2", SqlDbType.DateTime2 -> ... would never fire
unless the column happened to be literally named "datetime2".
The correct fix is to match on `dbType` alone, which always contains the
actual SQL type. This ensures that all DateTime2, DateTimeOffset and Time
TVP columns use SqlMetaData(name, dbType, 0uy, scale) rather than
SqlMetaData(name, dbType, precision, scale), avoiding the ArgumentException
"Metadata for field 'X' did not match the original record's metadata"
when the precision byte doesn't equal what SQL Server expects.
Closes #393
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent ac79dd6 commit bb614e4
1 file changed
Lines changed: 8 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
549 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
550 | 554 | | |
551 | 555 | | |
552 | 556 | | |
| |||
0 commit comments