System.Data.DataRow.SetNestedParentRow C# (CSharp) Method

SetNestedParentRow() private method

private SetNestedParentRow ( DataRow parentRow, bool setNonNested ) : void
parentRow DataRow
setNonNested bool
return void
        internal void SetNestedParentRow(DataRow parentRow, bool setNonNested)
        {
            if (parentRow == null)
            {
                SetParentRowToDBNull();
                return;
            }

            foreach (DataRelation relation in _table.ParentRelations)
            {
                if (relation.Nested || setNonNested)
                {
                    if (relation.ParentKey.Table == parentRow._table)
                    {
                        object[] parentKeyValues = parentRow.GetKeyValues(relation.ParentKey);
                        SetKeyValues(relation.ChildKey, parentKeyValues);

                        if (relation.Nested)
                        {
                            if (parentRow._table == _table)
                            {
                                CheckForLoops(relation);
                            }
                            else
                            {
                                GetParentRow(relation);
                            }
                        }
                    }
                }
            }
        }

Usage Example

Example #1
0
 private void AttachRows(DataRow parentRow, XmlNode parentElement)
 {
     if (parentElement != null)
     {
         for (XmlNode node = parentElement.FirstChild; node != null; node = node.NextSibling)
         {
             if (node.NodeType == XmlNodeType.Element)
             {
                 XmlElement e = (XmlElement)node;
                 DataRow    rowFromElement = this.GetRowFromElement(e);
                 if ((rowFromElement != null) && (rowFromElement.RowState == DataRowState.Detached))
                 {
                     if (parentRow != null)
                     {
                         rowFromElement.SetNestedParentRow(parentRow, false);
                     }
                     rowFromElement.Table.Rows.Add(rowFromElement);
                 }
                 else if (rowFromElement == null)
                 {
                     this.AttachRows(parentRow, node);
                 }
                 this.AttachRows(rowFromElement, node);
             }
         }
     }
 }
All Usage Examples Of System.Data.DataRow::SetNestedParentRow