public TableRow GetRow(RowId rowid) { if (rowid.ToInt64() != 0) throw new ArgumentOutOfRangeException("rowid"); if (row == null) { row = new TableRow(this, new RowId(0)); for (int i = 0; i < columns.Count; i++) row.SetValue(i, values[i]); } return row; }
public TableRow GetRow(RowId rowid) { // Null value if the rowid is less than 0 if (rowid == null || rowid.ToInt64() < 0) return null; int sz = Columns.Count; TableRow row = new TableRow(this, rowid); for (int i = 0; i < sz; i++) { int tableIndex = columns.IndexOfTable(i); // Adjust the column to the table the column is located int tableColumn = columns.AdjustColumn(i); // Adjust the row by the table RowId tableRow = AdjustRow(rowid.ToInt64(), tableIndex); // Fetch and return the data SqlObject value = tables[tableIndex].GetValue(tableColumn, tableRow); TableColumn column = Columns[i]; row.SetValue(column.Offset, value); } return row; }
public void Update(TableRow row) { queryString = row[0]; int sz = row.Table.Columns.Count; parameters.Clear(); for (int i = 1; i < sz; i++) { parameters.Add(row[i]); } currentRow = row; }
public TableRow NewRow() { currentRow = new ParameterRow(this, new RowId(0)); return currentRow; }
public TableRow NewRow() { if (currentRow == null) { currentRow = new QueryTableRow(this, new RowId(0)); } return currentRow; }
public void Undo() { currentRow = null; }
public void Delete(RowId rowid) { if (rowid.ToInt64() != 0) throw new ArgumentException(); queryString = null; parameters.Clear(); currentRow = null; rowCount--; }
public void Insert(TableRow row) { Update(row); rowCount++; }
public long InsertRow() { if (currentRow != null) throw new InvalidOperationException("Already updating a row"); TableRow insertedRow = backedTable.NewRow(); // Set up the inserted row to its default values TableName backedTname = BackedTableName; if (backedTname != null) SqlInterpreter.SetInsertRowToDefault(transaction, backedTname, backedTable, insertedRow.Id); updateType = 'I'; oldRowIndex = GetCurrentRowCursor().Count; currentRow = insertedRow; return oldRowIndex; }
public virtual void Update(TableRow row) { throw new NotSupportedException(); }
public void Insert(TableRow row) { currentRow = row; }
public void Update(TableRow row) { if (rows.ContainsKey(row.Id)) { rows[row.Id] = row; } }
public void Delete(RowId rowid) { currentRow = null; }
public void Update(TableRow row) { currentRow = row; }
public void Finish(bool commit) { if (updateType == ' ') throw new InvalidOperationException("No update operations"); try { // We get the index before we complete the operation. This ensures // the original iterator will not be corrupted by the complete // operation. // Get the index (this may need to copy the index from the view). IIndex<RowId> index = null; if (commit) { index = GetCurrentIndex(); } // If we are to do the operation, if (commit) { // Get the native table name being updated, TableName backedTname = BackedTableName; // Perform the operation via the SQLIterpreter. The interpreter // checks for immediate referential constraint violations and // updates any indexes on the table. // Note that these operations may change the state of // 'original_iterator' if (updateType == 'U') { // Update indexes, check integrity, etc // This may generate an exception and fail the operation. if (backedTname != null) { SqlInterpreter.CompleteRowUpdate(transaction, backedTable, backedTname, updatedRow.Id, currentRow.Id); } // Remove the value at the old position and insert a new value index.RemoveAt(oldRowIndex); index.Insert(currentRow.Id, oldRowIndex); backedTable.Update(currentRow); } else if (updateType == 'I') { // Update indexes, check integrity, etc // This may generate an exception and fail the operation. if (backedTname != null) { SqlInterpreter.CompleteRowInsert(transaction, backedTable, backedTname, currentRow.Id); } // Insert the row identifier on the end of the index index.Add(currentRow.Id); backedTable.Insert(currentRow); } else if (updateType == 'R') { // Update indexes, check integrity, etc // This may generate an exception and fail the operation. if (backedTname != null) { SqlInterpreter.CompleteRowRemove(transaction, backedTable, backedTname, currentRow.Id); } // Remove the entry from the index index.RemoveAt(oldRowIndex); } else { // This should never be able to happen throw new ApplicationException("Unexpected update type: " + updateType); } // Invalidate the current select iterator. currentSelect = null; } else { // Fail the operation backedTable.Undo(); } } finally { // Ensure we invalidate all this state information updateType = ' '; oldRowIndex = -1; currentRow = null; } }
public void UpdateRow(long rowIndex) { if (currentRow != null) throw new InvalidOperationException("Already updating a row"); RowId toUpdateRowid = GetRowId(rowIndex); TableRow toUpdateRow = backedTable.GetRow(toUpdateRowid); updateType = 'U'; oldRowIndex = rowIndex; updatedRow = toUpdateRow; currentRow = toUpdateRow; }
public void RemoveRow(long rowIndex) { if (currentRow != null) { throw new InvalidOperationException("Already updating a row"); } RowId toRemoveRowid = GetRowId(rowIndex); TableRow toRemoveRow = backedTable.GetRow(toRemoveRowid); // Note the remove happens immediately, so we need to make a copy of the // index now so the 'completeOperation' will work correctly. // This is a little bit messy. Perhaps we should change the contract of // 'removeRow' in MutableTableDataSource so the actual remove happens // when we call completeOperation? GetCurrentIndex(); // NOTE, we call this method for its side effect // Remove the row backedTable.Delete(toRemoveRowid); updateType = 'R'; oldRowIndex = rowIndex; currentRow = toRemoveRow; }
public void Insert(TableRow row) { rows[row.Id] = row; rowIndex.Add(row.Id); }
public void Insert(TableRow row) { throw new NotSupportedException(); }