public List <DbData> GetTableData(string tableName, int start = 0, int length = -1) {//select * from(select t.*,ROWNUM r from pt_oper_log t )where r>50 and r<=100 string row = "row" + Guid.NewGuid().ToString("N").Substring(24); //private string _sqlFormat = "select * from (select t.*, rownum {0} from ({1}) t where rownum <= {2}) where {0} > {3}"; string sql = "select * from(select t.*,ROWNUM " + row + " from " + tableName + " t) where " + row + ">" + start; if (length > 0) { sql += " and " + row + "<=" + (start + length); } DataTable dt = _oracleHelper.ExecuteDataTable(sql); List <DbData> datas = new List <DbData>(); OracleTableClass otc = GetTable(tableName) as OracleTableClass; string[] tableColumnNames = new string[dt.Columns.Count - 1]; object[] tableColumnDbTypes = new object[dt.Columns.Count - 1]; Type[] tableColumnTypes = new Type[dt.Columns.Count - 1]; for (int i = 0; i < dt.Columns.Count - 1; i++) { tableColumnNames[i] = dt.Columns[i].ColumnName; tableColumnTypes[i] = dt.Columns[i].DataType; if (otc != null) { tableColumnDbTypes[i] = MyDbHelper.GetDbDataType(Convert.ToString(((OracleTableColClass)(otc[dt.Columns[i].ColumnName])).data_type), MyDbType.Oracle, MyDbType.Oracle); } else { tableColumnDbTypes[i] = dt.Columns[i].DataType; } } foreach (DataRow item in dt.Rows) { TableDataRow tdr = new TableDataRow(); tdr.dbType = MyDbType.Oracle; object[] tableValues = new object[dt.Columns.Count - 1]; for (int i = 0; i < dt.Columns.Count - 1; i++) { tableValues[i] = item.ItemArray[i]; } DbData dbData = new DbData(MyDbType.Oracle, tableName, tableColumnNames, tableColumnTypes, tableColumnDbTypes, tableValues); datas.Add(dbData); } return(datas); }
public DbData(TableDataRow tableDataRow) { _tableDataRow = tableDataRow; }
public DbData(MyDbType dbType, string tableName, string[] tableColumnNames, Type[] tableColumnTypes, object[] tableColumnDbTypes, object[] tableValues=null) { _tableDataRow = new TableDataRow(dbType, tableName, tableColumnNames, tableColumnTypes, tableColumnDbTypes, tableValues); }
public DbData(MyDbType dbType, string tableName, string[] tableColumnNames, Type[] tableColumnTypes, object[] tableColumnDbTypes, object[] tableValues = null) { _tableDataRow = new TableDataRow(dbType, tableName, tableColumnNames, tableColumnTypes, tableColumnDbTypes, tableValues); }
public List<DbData> GetTableData(string tableName, int start = 0, int length = -1) { //select * from(select t.*,ROWNUM r from pt_oper_log t )where r>50 and r<=100 string row="row"+Guid.NewGuid().ToString("N").Substring(24); //private string _sqlFormat = "select * from (select t.*, rownum {0} from ({1}) t where rownum <= {2}) where {0} > {3}"; string sql = "select * from(select t.*,ROWNUM " + row + " from " + tableName + " t) where " + row + ">" + start; if (length>0) { sql += " and " + row + "<=" + (start + length); } DataTable dt = _oracleHelper.ExecuteDataTable(sql); List<DbData> datas = new List<DbData>(); OracleTableClass otc = GetTable(tableName) as OracleTableClass; string[] tableColumnNames = new string[dt.Columns.Count-1]; object[] tableColumnDbTypes = new object[dt.Columns.Count-1]; Type[] tableColumnTypes = new Type[dt.Columns.Count-1]; for (int i = 0; i < dt.Columns.Count-1; i++) { tableColumnNames[i] = dt.Columns[i].ColumnName; tableColumnTypes[i] = dt.Columns[i].DataType; if (otc != null) { tableColumnDbTypes[i] = MyDbHelper.GetDbDataType(Convert.ToString(((OracleTableColClass)(otc[dt.Columns[i].ColumnName])).data_type), MyDbType.Oracle, MyDbType.Oracle); } else { tableColumnDbTypes[i] = dt.Columns[i].DataType; } } foreach (DataRow item in dt.Rows) { TableDataRow tdr = new TableDataRow(); tdr.dbType = MyDbType.Oracle; object[] tableValues = new object[dt.Columns.Count - 1]; for (int i = 0; i < dt.Columns.Count - 1; i++) { tableValues[i] = item.ItemArray[i]; } DbData dbData = new DbData(MyDbType.Oracle, tableName, tableColumnNames, tableColumnTypes, tableColumnDbTypes, tableValues); datas.Add(dbData); } return datas; }