DapperLib / Dapper

Dapper - a simple object mapper for .Net
https://www.learndapper.com/
Other
17.56k stars 3.67k forks source link

ulong support please :) For MSSQL #2110

Open AlaskanDruid opened 2 months ago

AlaskanDruid commented 2 months ago

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.'

mgravell commented 2 months ago

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

AlaskanDruid commented 1 month ago

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 :/

mgravell commented 1 month ago

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

AlaskanDruid commented 1 month ago

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.

mgravell commented 1 month ago

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.