How to add MySQL dynamic LIMIT clause?
Drizin opened this issue · 2 comments
Drizin commented
Someone sent me a private email with this question:
Thanks for your repo.
I have some question about it , how can I do the limit with this one ?var q = cn // SQL .QueryBuilder($@"select a.*,b.cus_alias from shp_bah a left join cus_cus b on b.cus_nbr=a.cus_nbr /**where**/ limit {qs.size} ");
SQL :
select a.*,b.cus_alias from shp_bah a left join cus_cus b on b.cus_nbr=a.cus_nbr /**where**/ limit @p0
Cuz this will be syntax error with mysql.
Thanks.
Lin ******@gmail.com
Drizin commented
My answer:
Hi Lin,
You can use the "raw" format specifier. Unfortunately that only works with string type, so you should use this:
limit {qs.size.ToString():raw}
Let me know if it works.
Drizin commented
User confirmed it's working:
So nice . I succeeded with that.
Thanks . This is an awesome opensource for me.