Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Dynamic Parameters Naming for DB2

Open bhassel-lincoln opened this issue 7 years ago • 2 comments

Using Dapper for DB2 queries with the IBM.Data.DB2.iSeries driver works well, but there is an issue with the way parameters are handled. DB2 supports named parameters (and positional), but the parameter name MUST begin with the @ symbol, which DynamicParameters strips off by default: https://github.com/StackExchange/Dapper/blob/4e62055c5775aced61b848282ed180de0ab62161/Dapper/DynamicParameters.cs#L139

If the parameters are not named with the @ symbol, the variable matching defaults to positional within the statement, which can introduce hard-to-find bugs.

Because that Clean method is private/static, I don't see an easy way to change that default behavior. Is there some way to make that 'Clean' function optional at the connection/command level?

bhassel-lincoln avatar Oct 09 '18 17:10 bhassel-lincoln

https://github.com/amohata007/Hacktoberfest contribute here....it is totally awesome and very easy to contribute. @bhassel-lincoln @jbattermann @aggieben @paulcbetts @SamSaffron

amohata007 avatar Oct 10 '18 01:10 amohata007

https://www.ibm.com/docs/en/i/7.3?topic=variables-in-dynamic-sql states that named parameters are not supported in "dynamic SQL statements" (which i believe applies here)

fuetgeo avatar Oct 16 '24 12:10 fuetgeo