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

UpdateAsync throws error: Must declare the scalar variable "@u_0" #306

Open
JN-Lemon opened this issue Sep 21, 2022 · 1 comment
Open

UpdateAsync throws error: Must declare the scalar variable "@u_0" #306

JN-Lemon opened this issue Sep 21, 2022 · 1 comment

Comments

@JN-Lemon
Copy link

Database: SQL Server 2019

The POCO is just a generic class I whipped up that abides by the standards set in this repo. My key column is "Id" but it fails to properly map this column during an attempt to update.

I've downloaded the source and stepped through the code as it's trying to perform the SQL generation but I'm not seeing a @u_0 parameter being created in the DynamicParameters. @valfrid-ly I'm willing to dig in and help you figure this one out but it's well over my head. This seems like this bug breaks the usability of this entire library as an update crud operation is pretty significant.

@JN-Lemon
Copy link
Author

I believe the issue lies in DapperImplementor.cs within the InternalUpdate method starting at line 745

At line 751 it attempts to build the dynamic parameters but instead of building the @u_0 parameter the DynamicParameters contains a parameter at the bottom with the key column name like "Id_0"

The sql that's generated however is trying to update the key column with parameter "@u_0"

Which begs another question, why is the update trying to change the primary key column?

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

No branches or pull requests

1 participant