How does Dapper help protect against SQL injections? I am testing out different DAL technologies and have to choose one to be secure our site. I’m leaning towards Dapper (http://code.google.com/p/dapper-dot-net/), but need some help learning about security.
How does Dapper help protect against SQL injections? I am testing out different DAL
Share
It makes it really, really easy to do fully parameterized data access, without ever needing to either concatenate input. In particular, because you don’t need to jump through lots of “add parameter, set the parameter type, check for null because ADO.NET has sucky null-handling, rinse/repeat for 20 parameters”, by making parameter handling stupidly convenient. It also makes turning rows into objects really easy, avoiding the temptation to use
DataTable… everyone wins.From comments:
To answer, let’s take the example from marc_s’s reply, and write it the old way, assuming all we have to start with is
connection. This is then:except I’ve over-simplfied grossly, as it also deals with a wide range of issues such as:
AddWithValuerarely exists)dynamic(for multi-column) or primitives etc (for single column) when the output doesn’t warrant generation a POCO / DTODataTable