internal void SetParentRowToDBNull(DataRelation relation) { Debug.Assert(relation != null, "The relation should not be null here."); if (this.Table == null) { throw ExceptionBuilder.ChildRowNotInTheTable(); } if (relation.ChildKey.Table != this.Table) { throw ExceptionBuilder.SetParentRowTableMismatch(relation.ChildKey.Table.TableName, this.Table.TableName); } if (tempRecord == -1) { BeginEdit(); } int count = relation.ChildKey.Columns.Length; for (int i = 0; i < count; i++) { this[relation.ChildKey.Columns[i]] = DBNull.Value; } if (tempRecord == -1) { EndEdit(); } }
internal void SetParentRowToDBNull() { if (this.Table == null) { throw ExceptionBuilder.ChildRowNotInTheTable(); } foreach (DataRelation relation in this.Table.ParentRelations) { SetParentRowToDBNull(relation); } }
/// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.SetParentRow1"]/*' /> /// <devdoc> /// <para> /// Sets current row's parent row with specified relation. /// </para> /// </devdoc> public void SetParentRow(DataRow parentRow, DataRelation relation) { if (relation == null) { SetParentRow(parentRow); return; } if (parentRow == null) { SetParentRowToDBNull(relation); return; } if (this.Table == null) { throw ExceptionBuilder.ChildRowNotInTheTable(); } if (parentRow.Table == null) { throw ExceptionBuilder.ParentRowNotInTheTable(); } if (this.Table.DataSet != parentRow.Table.DataSet) { throw ExceptionBuilder.ParentRowNotInTheDataSet(); } if (relation.ChildKey.Table != this.Table) { throw ExceptionBuilder.SetParentRowTableMismatch(relation.ChildKey.Table.TableName, this.Table.TableName); } if (relation.ParentKey.Table != parentRow.Table) { throw ExceptionBuilder.SetParentRowTableMismatch(relation.ParentKey.Table.TableName, parentRow.Table.TableName); } object[] parentKeyValues = parentRow.GetKeyValues(relation.ParentKey); this.SetKeyValues(relation.ChildKey, parentKeyValues); }
/// <include file='doc\DataRow.uex' path='docs/doc[@for="DataRow.SetParentRow"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void SetParentRow(DataRow parentRow) { if (parentRow == null) { SetParentRowToDBNull(); return; } if (this.Table == null) { throw ExceptionBuilder.ChildRowNotInTheTable(); } if (parentRow.Table == null) { throw ExceptionBuilder.ParentRowNotInTheTable(); } foreach (DataRelation relation in this.Table.ParentRelations) { if (relation.ParentKey.Table == parentRow.Table) { object[] parentKeyValues = parentRow.GetKeyValues(relation.ParentKey); this.SetKeyValues(relation.ChildKey, parentKeyValues); if (relation.Nested) { if (parentRow.Table == this.Table) { this.CheckForLoops(relation); } else { this.GetParentRow(relation); } } } } }