Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Buildstarted opened this issue Nov 18, 2023 · 1 comment · Fixed by #120
Closed

Comments

@Buildstarted
Copy link

Buildstarted commented Nov 18, 2023

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
Copy link
Owner

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

andrewlock added a commit that referenced this issue Dec 1, 2023
* Add basic support for parsing decimal as IDs in Dapper

Fixes #118

* Explicitly test decimal conversion with Sqlserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants