使用 FluentData 3.0 對 28 筆資料分頁 (PageSize=10) 時發現:第 1 頁 10 筆、第 2 頁 18 筆、第 3 頁 8 筆,總計 36 筆 (重複 + 遺漏)。
-- 第 1 頁 (正確)
SELECT * FROM orders ORDER BY orderid LIMIT 0, 10;
-- 第 2 頁 (錯誤:offset=10, rows=20)
SELECT * FROM orders ORDER BY orderid LIMIT 10, 20;
-- 第 3 頁 (錯誤:offset=20, rows=30)
SELECT * FROM orders ORDER BY orderid LIMIT 20, 30;
MySQL LIMIT offset, rows 中 rows 應固定為 PageSize,但 FluentData 錯誤計算為 PageSize * PageNumber。
檔案:FluentData\Providers\MysqlProvider.cs
// 錯誤邏輯
sql += string.Format(" LIMIT {0}, {1}", data.GetFromItems() - 1, data.GetToItems());
// GetToItems() 回傳 PageSize * PageNumber (累積筆數)
// 正確:第二參數固定為 PageSize
sql += string.Format(" LIMIT {0}, {1}", data.GetFromItems() - 1, data.PagingItemsPerPage);
-- 修復後
Page 1: LIMIT 0, 10
Page 2: LIMIT 10, 10
Page 3: LIMIT 20, 10
重新編譯 FluentData 專案並替換 DLL,分頁恢復正常。