✅ How to use Dapper with Query Parameters
I work a lot with SQL databases such as MySQL, SQLite and PSQL and usually I write my Queries like this
But using Dapper if i want to create an Object from a
SELECT
query I need to run connection.Query<ObjectModel>("MyQuery");
, is there any way I can use Dapper while keeping my queries secure?19 Replies
there is also string parameters
https://www.learndapper.com/parameters#dapper-dynamic-parameters
and other ways
oh
i do have a followup question about Parameters in general
1. Do they prevent SQL Injection things
2. Do they also prevent errors that can happen if my WHERE clause has a target with spaces and such, cause i had massive trouble searching for GUID / UUID format
they prevent any issues related to formatting and sanitization of the query
alright! Thanks
1) yes its parametized
2) yes
they also have parametized where
the query and parameters are sent to the server separately so they can't possibly affect how the query executes
I love dapper it wouldve been a shame if it didnt have that :SCgetoutofmyhead:
not a dapper thing
just a SQL thing
yep
nono like
I mean even Ado have that
i mean executing with parameterized etc
which is ancient
yeah that's just sql
oki
thanks!
$close
Use the /close command to mark a forum thread as answered