Is there any reason why the following code wouldn't be retrieved in the correct order when using dapper?
connection.Query<User>("SELECT id, name " +
"FROM user " +
"ORDER BY @sort @dir " +
"LIMIT @offset, @pageSize; ",
new {
sort = sortOrder, // sortOrder = "name"
dir = sortDirection, // sortDirection = "ASC"
offset = pageIndex * pageSize, // offset = 0
pageSize = pageSize // pageSize = 10
});
It always returns without applying the ordering.
I could just place the sortOrder and sortDirection directly into the string like this
"SELECT id, name " +
"FROM user " +
"ORDER BY " + sortOrder + " " + sortDirection + " " +
"LIMIT @offset, @pageSize; "
but I'm not sure how that will effect dapper since I believe it has it's own query plan caching.
Also, is there a way to view the query that is generated by dapper?