DapperLib / Dapper

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

Dynamic Parameters Naming for DB2 #1138

Open bhassel-lincoln opened 6 years ago

bhassel-lincoln commented 6 years ago

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?

amohata007 commented 6 years ago

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

fuetgeo commented 1 month ago

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)