/// <summary> /// 查询列表(分页) /// </summary> /// <param name="strSql">sql语句</param> /// <param name="dbParameter">参数</param> /// <param name="pagination">分页数据</param> /// <returns></returns> public DataTable FindTable(string strSql, object dbParameter, Pagination pagination) { int total = pagination.records; pagination.sidx = SqlHelper2.SqlFilters(pagination.sidx); DataTable data; if (dbWhere != null) { int orderIndex = strSql.ToUpper().IndexOf("ORDER BY"); if (orderIndex > 0) { strSql = strSql.Substring(0, orderIndex); string orderString = strSql.Substring(orderIndex); strSql = string.Format(" select * From ({0})t Where {1} {2} ", strSql, dbWhere.sql, orderString); } else { strSql = string.Format(" select * From ({0})t Where {1} ", strSql, dbWhere.sql); } DynamicParameters dynamicParameters = SqlHelper.FieldValueParamToParameter(dbWhere.dbParameters); dynamicParameters.AddDynamicParams(dbParameter); data = db.FindTable(strSql, dynamicParameters, pagination.sidx, pagination.sord.ToLower() == "asc" ? true : false, pagination.rows, pagination.page, out total); } else { data = db.FindTable(strSql, dbParameter, pagination.sidx, pagination.sord.ToLower() == "asc" ? true : false, pagination.rows, pagination.page, out total); } pagination.records = total; return(data); }
/// <summary> /// 查询列表(分页) /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="condition">表达式</param> /// <param name="pagination">分页数据</param> /// <returns></returns> public IEnumerable <T> FindList <T>(Expression <Func <T, bool> > condition, Pagination pagination) where T : class, new() { int total = pagination.records; pagination.sidx = SqlHelper2.SqlFilters(pagination.sidx); if (string.IsNullOrEmpty(pagination.sidx)) { pagination.sidx = ""; pagination.sord = "asc"; } var data = db.FindList <T>(condition, pagination.sidx, pagination.sord.ToLower() == "asc" ? true : false, pagination.rows, pagination.page, out total); pagination.records = total; return(data); }
/// <summary> /// 查询列表(分页) /// </summary> /// <typeparam name="T">类型</typeparam> /// <param name="strSql">SQL语句</param> /// <param name="dbParameter">参数</param> /// <param name="pagination">分页数据</param> /// <returns></returns> public IEnumerable <T> FindList <T>(string strSql, object dbParameter, Pagination pagination) where T : class { int total = pagination.records; pagination.sidx = SqlHelper2.SqlFilters(pagination.sidx); if (string.IsNullOrEmpty(pagination.sidx)) { pagination.sidx = ""; pagination.sord = "asc"; } if (dbWhere != null) { int orderIndex = strSql.ToUpper().IndexOf("ORDER BY"); if (orderIndex > 0) { strSql = strSql.Substring(0, orderIndex); string orderString = strSql.Substring(orderIndex); strSql = string.Format(" select * From ({0})t Where {1} {2} ", strSql, dbWhere.sql, orderString); } else { strSql = string.Format(" select * From ({0})t Where {1} ", strSql, dbWhere.sql); } DynamicParameters dynamicParameters = SqlHelper.FieldValueParamToParameter(dbWhere.dbParameters); dynamicParameters.AddDynamicParams(dbParameter); var data = db.FindList <T>(strSql, dynamicParameters, pagination.sidx, pagination.sord.ToLower() == "asc" ? true : false, pagination.rows, pagination.page, out total); pagination.records = total; return(data); } else { var data = db.FindList <T>(strSql, dbParameter, pagination.sidx, pagination.sord.ToLower() == "asc" ? true : false, pagination.rows, pagination.page, out total); pagination.records = total; return(data); } }