protected override void InternalSelect(IRow row) { _sourceTable.Select(_sourceRow); int columnIndex; for (int index = 0; index < Node.DataType.Columns.Count; index++) { if (!((IList)Node.RedefineColumnOffsets).Contains(index)) { columnIndex = row.DataType.Columns.IndexOfName(DataType.Columns[index].Name); if (columnIndex >= 0) { if (_sourceRow.HasValue(index)) { row[columnIndex] = _sourceRow[index]; } else { row.ClearValue(columnIndex); } } } } Program.Stack.Push(_sourceRow); try { for (int index = 0; index < Node.RedefineColumnOffsets.Length; index++) { columnIndex = row.DataType.Columns.IndexOfName(Node.DataType.Columns[Node.RedefineColumnOffsets[index]].Name); if (columnIndex >= 0) { row[columnIndex] = Node.Nodes[index + 1].Execute(Program); } } } finally { Program.Stack.Pop(); } }
public void CopyTo(IRow row) { int columnIndex; for (int index = 0; index < DataType.Columns.Count; index++) { columnIndex = row.IndexOfColumn(DataType.Columns[index].Name); if (columnIndex >= 0) { if (HasValue(index)) { row[columnIndex] = this[index]; } else { row.ClearValue(columnIndex); } } } }
protected override void InternalSelect(IRow row) { _sourceTable.Select(_sourceRow); _sourceRow.CopyTo(row); Program.Stack.Push(_sourceRow); try { int nodeIndex; int columnIndex; for (int index = 0; index < DataType.Columns.Count; index++) { columnIndex = row.DataType.Columns.IndexOfName(DataType.Columns[index].Name); if (columnIndex >= 0) { nodeIndex = (index - Node.AggregateColumnOffset) + 1; if (nodeIndex >= 1) { row[columnIndex] = Node.Nodes[nodeIndex].Execute(Program); } else { if (_sourceRow.HasValue(index)) { row[columnIndex] = _sourceRow[index]; } else { row.ClearValue(columnIndex); } } } } } finally { Program.Stack.Pop(); } }
// Copies the values from source row to the given target row, without using stream referencing // ASourceRow and ATargetRow must be of equivalent row types. protected void MarshalRow(IRow sourceRow, IRow targetRow) { for (int index = 0; index < sourceRow.DataType.Columns.Count; index++) { if (sourceRow.HasValue(index)) { if (sourceRow.HasNonNativeValue(index)) { Scalar scalar = new Scalar(targetRow.Manager, (Schema.ScalarType)sourceRow.DataType.Columns[index].DataType); Stream sourceStream = sourceRow.GetValue(index).OpenStream(); try { Stream targetStream = scalar.OpenStream(); try { StreamUtility.CopyStream(sourceStream, targetStream); } finally { targetStream.Close(); } } finally { sourceStream.Close(); } targetRow[index] = scalar; } else { targetRow[index] = sourceRow[index]; } } else { targetRow.ClearValue(index); } } }
protected override void InternalSelect(IRow row) { // alternative rename algorithm could construct a row of the source type first _sourceTable.Select(_sourceRow); int columnIndex; for (int index = 0; index < row.DataType.Columns.Count; index++) { columnIndex = DataType.Columns.IndexOfName(row.DataType.Columns[index].Name); if (columnIndex >= 0) { if (_sourceRow.HasValue(columnIndex)) { row[index] = _sourceRow[columnIndex]; } else { row.ClearValue(index); } } } }
/// <summary> Initializes row values with default data. </summary> protected override void InternalInitializeRow(IRow row) { Process.BeginTransaction(IsolationLevel); try { if (IsMasterSetup() && !MasterSource.DataSet.IsEmpty()) { Row originalRow = new Row(row.Manager, row.DataType); try { Schema.TableVarColumn column; DataField field; DataField detailField; for (int index = 0; index < _masterKey.Columns.Count; index++) { column = _masterKey.Columns[index]; field = MasterSource.DataSet.Fields[column.Name]; if (_fields.Contains(_detailKey.Columns[index].Name)) { detailField = Fields[_detailKey.Columns[index].Name]; if (field.HasValue()) { IRow saveOldRow = _oldRow; _oldRow = originalRow; try { row[detailField.Name] = field.Value; try { _isModified = InternalColumnChanging(detailField, originalRow, row) || _isModified; } catch { row.ClearValue(detailField.Name); throw; } _isModified = InternalColumnChanged(detailField, originalRow, row) || _isModified; } finally { _oldRow = saveOldRow; } } } } } finally { originalRow.Dispose(); } } bool saveIsModified = _isModified; try { base.InternalInitializeRow(row); } finally { _isModified = saveIsModified; } Process.CommitTransaction(); } catch (Exception e) { try { Process.RollbackTransaction(); } catch (Exception rollbackException) { throw new DAE.Server.ServerException(DAE.Server.ServerException.Codes.RollbackError, e, rollbackException.ToString()); } throw; } }