andrewlock / StronglyTypedId

A Rosyln-powered generator for strongly-typed IDs
MIT License
1.53k stars 82 forks source link

DapperTypeHandler for int type doesn't handle decimal return types from the database #118

Closed Buildstarted closed 10 months ago

Buildstarted commented 10 months ago

In MSSQL SCOPE_IDENTITY() and @@IDENTITY must encompass several numeric types for table ids.

https://learn.microsoft.com/en-us/sql/t-sql/functions/scope-identity-transact-sql?view=sql-server-ver16

The return type for both builtins is numeric(38,0) (which is converted to decimal in c#) but there is no decimal handler in DapperTypeHandler.Parse. You can currently get around this by adding CAST(SCOPE_IDENTITY() AS INT) but this is not ideal if you have a lot of queries that return that identity value.

andrewlock commented 10 months ago

Thanks for flagging this, I'm hoping to get a fix out for this soon, as part of the big redesign of the library