吉日嘎拉DotNet.BusinessV4.2中的一处bug,及我的修复和扩展
2016-06-05 18:53
309 查看
bug所在位置:DotNet.Business\Utilities\BaseManager.GetDataTableByPage.cs的函数
public virtual DataTable GetDataTableByPage(out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null, string tableName = null, string conditional = null, IDbDataParameter[] dbParameters = null, string selectField = null)中。当使用自己定义的查询语句作为tableName传递进来的时候,按照逻辑没有使用存储过程进行分页,但是很明显那个传递的conditional和dbParameters都被用来统计了总记录数,但是以下调用语句并没有传递conditional。
return DbLogic.GetDataTableByPage(DbHelper, recordCount, pageIndex, pageSize, tableName, dbParameters, sortExpression, sortDire);
于是我扩展了那个DotNet.Business\Utilities\Extend\DbLogic.GetDataTableByPage.Extend.cs,增加了函数
public static DataTable GetDataTableByPage(IDbHelper dbHelper, int recordCount, int pageIndex, int pageSize, string sqlQuery, string conditional, IDbDataParameter[] dbParameters, string sortExpression = null, string sortDire = null)
这里的逻辑是,多表查询构造一个viewTable,然后将where查询直接传递到viewTable里面,而不受分页的影响。上个月扩展了此函数,今天正式升级服务器程序的时候,还是出现了问题,于是有了以上函数的完善版本。上个月是将where条件放在了最外面,造成ROW_NUMBER范围内的所有记录都没有指定where条件的记录,造成用户看记录的时候明明有,显示不出来。当然,这个扩展的函数仅仅是扩展了MSSQL的数据库,有类似使用的朋友可以参考。
public virtual DataTable GetDataTableByPage(out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null, string tableName = null, string conditional = null, IDbDataParameter[] dbParameters = null, string selectField = null)中。当使用自己定义的查询语句作为tableName传递进来的时候,按照逻辑没有使用存储过程进行分页,但是很明显那个传递的conditional和dbParameters都被用来统计了总记录数,但是以下调用语句并没有传递conditional。
return DbLogic.GetDataTableByPage(DbHelper, recordCount, pageIndex, pageSize, tableName, dbParameters, sortExpression, sortDire);
于是我扩展了那个DotNet.Business\Utilities\Extend\DbLogic.GetDataTableByPage.Extend.cs,增加了函数
public static DataTable GetDataTableByPage(IDbHelper dbHelper, int recordCount, int pageIndex, int pageSize, string sqlQuery, string conditional, IDbDataParameter[] dbParameters, string sortExpression = null, string sortDire = null)
这里的逻辑是,多表查询构造一个viewTable,然后将where查询直接传递到viewTable里面,而不受分页的影响。上个月扩展了此函数,今天正式升级服务器程序的时候,还是出现了问题,于是有了以上函数的完善版本。上个月是将where条件放在了最外面,造成ROW_NUMBER范围内的所有记录都没有指定where条件的记录,造成用户看记录的时候明明有,显示不出来。当然,这个扩展的函数仅仅是扩展了MSSQL的数据库,有类似使用的朋友可以参考。
相关文章推荐
- JAVA中的数组对象
- 1 PHP读取表数据
- Activity Bundle 方式传参
- 有关环形数组的约瑟夫问题
- 基于柯西矩阵的Erasure Code技术详解
- TCP/IP 七层协议
- 修改PHP上传文件大小限制的方法
- Java泛型让声明方法返回子类型
- Hadoop多个输出案例
- Why not implement deep copy in default copy constructor?
- css基础
- 一个屌丝程序猿的人生(二十二)
- c++--作业7
- c++作业7
- 正则表达式基本语法
- android产品研发(七)-->Apk热修复
- flask搭建个人博客(四)——前端模板
- BZOJ 3224 TYVJ 1728 普通平衡树 [Treap树模板]
- bzoj 2054: 疯狂的馒头
- java 开发界面利器WindowBuilder Pro 安装方法