Development Environment
FluentData3.0, VS. NET2010, and Mysql5.0
Problem description
When a table (with 28 records) is paged using FluentData, a strange problem is suddenly found. The first page returns 10 normal data records, and the second page returns 18 data records, the third page returns 8 data records
After code issues are eliminated, the generated paging SQL statements are obtained page by page.
Page 1: select * from orders order by orderid limit 0, 10
Page 2: select * from orders order by orderid limit 10, 20
Page 3: select * from orders order by orderid limit 20, 30
At first glance, it seems that there is no problem, but for those familiar with mysql paging, we should soon be able to see the problem. The second parameter of limit should be PageSize.
BUG Locating
The BUG source code is in FluentData \ Providers \ MysqlProvider. cs. The problem code is as follows:
sql = = ++= + (data.WhereSql.Length > += + (data.GroupBy.Length > += + (data.Having.Length > += + (data.OrderBy.Length > += + (data.PagingItemsPerPage > && data.PagingCurrentPage > += .Format(, data.GetFromItems() -
BUG fixes
SQL + =. Format (, data. GetFromItems ()-1, data. GetToItems ());
Should be changed
SQL + =. Format (, data. GetFromItems ()-1, data. PagingItemsPerPage );
After re-compilation, everything is normal. It is estimated that the author of FluentData did not test it in Mysql.
However, FluentData is indeed a very good lightweight ORM framework. It has made some packages and is easy to use.