jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
856 stars 145 forks source link

Map from decimal to money when using TVP #476

Closed nzbart closed 2 years ago

nzbart commented 2 years ago

When using table valued parameters, Insight needs to map from the .NET type (e.g. decimal) to the SQL Server type (e.g. decimal or money). The mapping from the decimal .NET type to decimal SQL Server type works by default, but if the type in SQL Server is money, values in the decimal places are truncated and lost. Since we know the data type in the database via metadata, use the same approach that has been taken for datetime2 (which also has multiple SQL Server types mapping to a single .NET type).

Note that this problem only seems to manifest itself in the .NET Standard build. The new test failed prior to fixing when run under .NET 5, but not under .NET 4.5.1. It could be that the .NET Framework SQL Server libraries are more forgiving of this situation.

Description

Fixes #475.

Checklist

Please make sure your pull request fulfills the following requirements:

Type

This pull request includes what type of changes?

Breaking Changes

Does this pull request introduce any breaking changes?

Any other comment

(n/a)