/// <summary> /// 获取源表的分页存储过程查询命令,如果获取失败则返回Null /// </summary> /// <param name="dba"></param> /// <param name="tableName"></param> /// <param name="pageSize"></param> /// <param name="pageNo"></param> /// <param name="fields"></param> /// <param name="where"></param> /// <param name="orderBy"></param> /// <param name="groupBy"></param> /// <returns></returns> private DbCommand getPagingSpCommand(string tableName, int pageSize, int pageNo, string fields, string where, string orderBy, string groupBy) { List <string> pks = dbAdmin.GetPrimaryKeys(tableName); if (pks == null || pks.Count != 1) { return(null); } DbCommand cmd = null; if (!dbAdmin.ExistsSp(DataSourceConst.PaginationSpName)) { dbAdmin.modifyProc(DataSourceConst.PaginationSpName, DataSourceConst.PaginationSpText); } cmd = dbAdmin.GetStoredProcCommand(DataSourceConst.PaginationSpName); cmd.CommandType = CommandType.StoredProcedure; dbAdmin.addInParameter(cmd, "@TableName", DbType.String, tableName); dbAdmin.addInParameter(cmd, "@PrimaryKey", DbType.String, pks[0]); dbAdmin.addInParameter(cmd, "@PageNo", DbType.Int32, pageNo); dbAdmin.addInParameter(cmd, "@PageSize", DbType.Int32, pageSize); dbAdmin.addInParameter(cmd, "@Where", DbType.String, where); dbAdmin.AddOutParameter(cmd, "@PageCount", DbType.Int32, sizeof(int)); dbAdmin.AddOutParameter(cmd, "@Total", DbType.Int32, sizeof(int)); return(cmd); }