protected virtual void AddCore(DataRelation relation)
{
DataCommonEventSource.Log.Trace("<ds.DataRelationCollection.AddCore|INFO> {0}, relation={1}", ObjectID, (relation != null) ? relation.ObjectID : 0);
if (relation == null)
{
throw ExceptionBuilder.ArgumentNull(nameof(relation));
}
relation.CheckState();
DataSet dataSet = GetDataSet();
if (relation.DataSet == dataSet)
{
throw ExceptionBuilder.RelationAlreadyInTheDataSet();
}
if (relation.DataSet != null)
{
throw ExceptionBuilder.RelationAlreadyInOtherDataSet();
}
if (relation.ChildTable.Locale.LCID != relation.ParentTable.Locale.LCID ||
relation.ChildTable.CaseSensitive != relation.ParentTable.CaseSensitive)
{
throw ExceptionBuilder.CaseLocaleMismatch();
}
if (relation.Nested)
{
relation.CheckNamespaceValidityForNestedRelations(relation.ParentTable.Namespace);
relation.ValidateMultipleNestedRelations();
relation.ParentTable.ElementColumnCount++;
}
}