您的位置:首页 > 其它

吉日嘎拉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的数据库,有类似使用的朋友可以参考。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: