internal void CheckNestedRelations()
{
DataCommonEventSource.Log.Trace("<ds.DataRelation.CheckNestedRelations|INFO> {0}", ObjectID);
Debug.Assert(DataSet == null || !_nested, "this relation supposed to be not in dataset or not nested");
// 1. There is no other relation (R) that has this.ChildTable as R.ChildTable
// This is not valid for Whidbey anymore so the code has been removed
// 2. There is no loop in nested relations
#if DEBUG
int numTables = ParentTable.DataSet.Tables.Count;
#endif
DataTable dt = ParentTable;
if (ChildTable == ParentTable)
{
if (string.Compare(ChildTable.TableName, ChildTable.DataSet.DataSetName, true, ChildTable.DataSet.Locale) == 0)
throw ExceptionBuilder.SelfnestedDatasetConflictingName(ChildTable.TableName);
return; //allow self join tables.
}
List<DataTable> list = new List<DataTable>();
list.Add(ChildTable);
// We have already checked for nested relaion UP
for (int i = 0; i < list.Count; ++i)
{
DataRelation[] relations = list[i].NestedParentRelations;
foreach (DataRelation rel in relations)
{
if (rel.ParentTable == ChildTable && rel.ChildTable != ChildTable)
{
throw ExceptionBuilder.LoopInNestedRelations(ChildTable.TableName);
}
if (!list.Contains(rel.ParentTable))
{
// check for self nested
list.Add(rel.ParentTable);
}
}
}
}