惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

腾讯CDC
Schneier on Security
Schneier on Security
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
A
About on SuperTechFans
Recorded Future
Recorded Future
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
Vercel News
Vercel News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
V2EX - 技术
V2EX - 技术
N
Netflix TechBlog - Medium
F
Fortinet All Blogs
V
Visual Studio Blog
Martin Fowler
Martin Fowler
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
The Exploit Database - CXSecurity.com
F
Full Disclosure
Scott Helme
Scott Helme
H
Heimdal Security Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
Cyberwarzone
Cyberwarzone
Application and Cybersecurity Blog
Application and Cybersecurity Blog
V
Vulnerabilities – Threatpost
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Troy Hunt's Blog
S
SegmentFault 最新的问题
Forbes - Security
Forbes - Security
Jina AI
Jina AI
S
Securelist
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
J
Java Code Geeks
AWS News Blog
AWS News Blog
N
News and Events Feed by Topic
博客园 - 三生石上(FineUI控件)
量子位

博客园 - kalman

nodejs+express+jade安装备忘 Asp.net MVC应用在IIS7上部署后403错误解决方案 【转】禁止从终端服务器复制文件 代码生成器Kalman Studio2.2发布,完美支持Oracle,不需要安装Oracle客户端 【备忘】Oracle常用系统表(做代码生成器用得到) 开发辅助工具Kalman Studio2.0发布,内置基于T4的代码生成器 如何在Yii Framework中使用PHPExcel组件【备忘】 T4代码生成器Kalman Studio发布 如何为Kalman Studio编写T4模板 - kalman - 博客园 发布基于T4模板引擎的代码生成器[Kalman Studio] 请谨慎设置WinForm控件DataGridView列的AutoSizeMode属性 安装apache_2.0.63-win32-x86出现no installed service named "apache2" - kalman .NET序列化与反序列化(转) 手工查杀Win32/Pacex.Gen,Win32/Genetik,Win32/PSW.Agent.NCC,Win32/PSW.QQPass.VD病毒 win2003下安装Look n Stop网络防火墙导致系统蓝屏(tcpip.sys - address F75F5390 base at F75B4000,DataStamp 4473b09e) 在线播放器代码大全(收藏) - kalman - 博客园 System.Exception: System.Data.OracleClient requires Oracle client software version 8.1.7 or greater 服务器: 消息 15135,级别 16,状态 1,过程 sp_validatepropertyinputs,行 100. 对象无效。不允许在 '.cash_flux' 上使用扩展属性,或对象不存在 Excel组件使用配置文档下载
FluentData Mysql分页的一个BUG
kalman · 2013-12-12 · via 博客园 - kalman

开发环境

FluentData3.0、VS.NET2010、Mysql5.0

问题描述

使用FluentData对一个表(记录数28)进行分页时,突然发现一个诡异的问题,第一页返回10条数据正常,第二页返回18条数据,第三页返回8条数据

在排除了代码问题后,逐页获取生成的分页SQL语句

第一页:select * from orders order by orderid limit 0,10

第二页:select * from orders order by orderid limit 10,20

第三页:select * from orders order by orderid limit 20,30

咋一看好像没什么问题,但是对于熟悉mysql分页的应该很快就可以看出问题所在,limit的第二个参数应该是PageSize

BUG定位

 该BUG源码在FluentData\Providers\MysqlProvider.cs,问题代码如下

public string GetSqlForSelectBuilder(SelectBuilderData data)
        {
            var sql = "";
            sql = "select " + data.Select;
            sql += " from " + data.From;
            if (data.WhereSql.Length > 0)
                sql += " where " + data.WhereSql;
            if (data.GroupBy.Length > 0)
                sql += " group by " + data.GroupBy;
            if (data.Having.Length > 0)
                sql += " having " + data.Having;
            if (data.OrderBy.Length > 0)
                sql += " order by " + data.OrderBy;
            if (data.PagingItemsPerPage > 0
                && data.PagingCurrentPage > 0)
            {
                sql += string.Format(" limit {0}, {1}", data.GetFromItems() - 1, data.GetToItems());
            }
            
            return sql;
        }

BUG修复

sql += string.Format(" limit {0}, {1}", data.GetFromItems() - 1, data.GetToItems());

应该改成

sql += string.Format(" limit {0}, {1}", data.GetFromItems() - 1, data.PagingItemsPerPage);

重新编译后一切正常,估计FluentData的作者在Mysql下没怎么测试

但是瑕不掩瑜,FluentData的确是一个非常优秀的轻量级ORM框架,自己做了一些封装,很好用