I'm testing out SubSonic, but I'm stuck on my first simple example. I have a news table that I'm trying to fetch the 10 latest results:
var newsItems = News.GetPaged("datecreated", 0, 10);
This results in this error:
[MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10, 10' at line 6]
The SQL generated:
SELECT `newsid`, `datecreated`, `headline`, `body`, `link`, `picture`, `linkinfo`, `postedby`, `comments`, `category` FROM news ORDER BY newsid DESC LIMIT -10,10
It's easy to fix the sql manually, but I don't have a clue on how to make SubSonic add a correct LIMIT to the query automatically. Any pointers?
The limit should be a positive integer starting from 0.
-10
,10 is not-The
LIMIT
clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).The SQL generated should have been
I think for
Subsonic
you need this