Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

ulong support please :) For MSSQL

Open AlaskanDruid opened this issue 1 year ago • 5 comments

Hellos,

I ran across this issue when trying to pass a ulong to MSSQL stored procedure via Dapper. I am running across an issue of storing a Steam Id (from Steamworks) to the database. it is of the ulong data type (max: 18,446,744,073,709,551,615). The easiest way to replicate the issue:

  1. Create a table with a field type of Numeric (20,0).
  2. Create a stored procedure that accepts a parameter type of Numeric(20, 0).
  3. Call stored procedure from Dapper, passing along a ulong.

You will get the following exception:

System.ArgumentException: 'The parameter data type of UInt64 is invalid.'

AlaskanDruid avatar Sep 09 '24 20:09 AlaskanDruid

question: does it work if you do this in raw ADO.NET?

mgravell avatar Sep 10 '24 09:09 mgravell

Wow... I had everything typed out with scripts and everything.. only to find out the ADO.Net does not support the MSSQL Numeric data type... uuuggghhhh. So its a missing data type in ADO.

After fiddling around some more with a workaround... convert everything to Decimals for the DTO objects, and then convert them to their proper ulong format for interacting with steamworks. So table field(s), stored procedure parameters and C# DTOs :/

AlaskanDruid avatar Sep 10 '24 20:09 AlaskanDruid

So: is there something that Dapper should do here? do you have an example of what you would like to work?

mgravell avatar Sep 13 '24 09:09 mgravell

I am currently unsure. I mean, if Microsoft's own ADO.Net is missing support for all of the MSSQL data types, I am unsure if Dapper could fix that... could it? Could Dapper support the MSSQL Numeric data type? (( for some reason, I thought Dapper was dependent on ADO.Net.

AlaskanDruid avatar Sep 13 '24 17:09 AlaskanDruid

Dapper is indeed dependent on ADO.NET; if the underlying driver (Microsoft.Data.SqlClient) supports something, we can try to ensure it works from Dapper.

mgravell avatar Sep 14 '24 07:09 mgravell