private void OnDataSetRelationsChanging(object oRelationsCollection, CollectionChangeEventArgs args)
{
// args.Action is one of CollectionChangeAction.Add, CollectionChangeAction.Remove or CollectionChangeAction.Refresh
// args.Element is a DataRelation
// Disallow changing the tables collection if there is data loaded and there are nested relationship that are added/refreshed
DataRelation rel = (DataRelation)(args.Element);
if (rel != null && rel.Nested)
throw new InvalidOperationException(SR.DataDom_DataSetNestedRelationsChange);
// If Add and Remove, we should already been throwing if .Nested == false
Debug.Assert(!(args.Action == CollectionChangeAction.Add || args.Action == CollectionChangeAction.Remove) || rel.Nested == false);
if (args.Action == CollectionChangeAction.Refresh)
{
foreach (DataRelation relTemp in (DataRelationCollection)oRelationsCollection)
{
if (relTemp.Nested)
{
throw new InvalidOperationException(SR.DataDom_DataSetNestedRelationsChange);
}
}
}
}