4
當使用dapper時,下面的代碼不會以正確的順序被檢索出來嗎?Dapper Order By
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
});
它總是返回而不應用排序。
我可以放置中將sortOrder和sortDirection直接串入這樣
"SELECT id, name " +
"FROM user " +
"ORDER BY " + sortOrder + " " + sortDirection + " " +
"LIMIT @offset, @pageSize; "
,但我不知道如何將影響短小精悍,因爲我相信它有它自己的查詢計劃緩存。
此外,有沒有辦法查看由dapper生成的查詢?
非常感謝您的快速響應! – JesseBuesking 2012-02-20 01:53:07