Is it better to avoid inlnine SQL with dapper?

dapper

Question

I have considered using dapper, but I still don't like the idea of using inline SQL. Are there any thoughts on just have stored procedures so in the event that there is a problem with the query, it would not need a recompilation, but just a change to a stored procedure in a database. Are there any alternatives such as keeping all SQL queries in it's own class library?

Accepted Answer

Dapper supports both options, and has no opinion on the topic.

Your question suggests that deployment of your codebase is tricky. If this is client-side code, that might make sense. For server-side code, it is usually easier to re-deploy the app than it is to change a stored procedure - ideally 1 click via something like TeamCity. Of course, your stored procedures should also have process / deployment control.

Having the SQL in a class library won't buy you much: you still need to re-deploy to get the changes. Of course, it may make sense to have your data-oriented code in separate assemblies to the UI (etc) code, but that is a local architecture decision.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why