public void Clear()
{
if (_table != null)
{
_table.PrimaryKey = null;
for (int i = 0; i < _table.ParentRelations.Count; i++)
{
_table.ParentRelations[i].SetChildKeyConstraint(null);
}
for (int i = 0; i < _table.ChildRelations.Count; i++)
{
_table.ChildRelations[i].SetParentKeyConstraint(null);
}
}
if (_table.fInitInProgress && _delayLoadingConstraints != null)
{
_delayLoadingConstraints = null;
_fLoadForeignKeyConstraintsOnly = false;
}
int oldLength = List.Count;
Constraint[] constraints = new Constraint[List.Count];
List.CopyTo(constraints, 0);
try
{
// this will smartly add and remove the appropriate tables.
BaseGroupSwitch(constraints, oldLength, null, 0);
}
catch (Exception e) when (Common.ADP.IsCatchableOrSecurityExceptionType(e))
{
// something messed up. restore to original state.
BaseGroupSwitch(null, 0, constraints, oldLength);
List.Clear();
for (int i = 0; i < oldLength; i++)
{
List.Add(constraints[i]);
}
throw;
}
List.Clear();
OnCollectionChanged(s_refreshEventArgs);
}