Closed nzbart closed 2 years ago
This change appears to fix the problem for me:
diff --git a/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs b/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs
index 442cfad..3d8c416 100644
--- a/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs
+++ b/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs
@@ -114,6 +114,8 @@ namespace Insight.Database.Providers.Default
return SqlDbType.DateTime;
case "datetime2":
return SqlDbType.DateTime2;
+ case "money":
+ return SqlDbType.Money;
}
}
I'm happy to create a pull request, but could do with some advice about where to write the tests. The closest, similar, test I can see is Datetime2FieldsShouldConvertInTVP
. Should I create one below that?
Yeah that’s a good place for a test. If you put in a pr i can do a build this weekend (along with the sql driver version update)
On May 5, 2022, at 9:11 PM, nzbart @.***> wrote:
This change appears to fix the problem for me:
diff --git a/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs b/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs index 442cfad..3d8c416 100644 --- a/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs +++ b/Insight.Database.Providers.Default/SqlDataRecordAdapter.cs @@ -114,6 +114,8 @@ namespace Insight.Database.Providers.Default return SqlDbType.DateTime; case "datetime2": return SqlDbType.DateTime2;
I'm happy to create a pull request, but could do with some advice about where to write the tests. The closest, similar, test I can see is Datetime2FieldsShouldConvertInTVP. Should I create one below that?
— Reply to this email directly, view it on GitHubhttps://github.com/jonwagner/Insight.Database/issues/475#issuecomment-1119198991, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAMTO5CFZ5CJAXECGS7YXWLVIR5UBANCNFSM5VARC3NQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
When using a table valued parameter with SQL Server type Money and C# type decimal, the decimal places are lost when sent to the database.
This problem does not appear to be present when running under the .NET Framework. Note that I have not attempted to reproduce this issue in any other .NET versions, so can't comment on which versions may have this problem. .NET 6 is the latest production .NET version.
Steps to reproduce
Create a C# project with the following files:
Program.cs
repro.csproj
Update the connection string to point to a SQL Server instance if you haven't got SQL Server running locally, and run the app using
dotnet run
. It will output the following:Expected behavior
I expect the output to be as follows, since decimal places should not be lost: