System.Data.DataRelation.CheckState C# (CSharp) Метод

CheckState() приватный Метод

private CheckState ( ) : void
Результат void
        internal void CheckState()
        {
            if (_dataSet == null)
            {
                _parentKey.CheckState();
                _childKey.CheckState();

                if (_parentKey.Table.DataSet != _childKey.Table.DataSet)
                {
                    throw ExceptionBuilder.RelationDataSetMismatch();
                }

                if (_childKey.ColumnsEqual(_parentKey))
                {
                    throw ExceptionBuilder.KeyColumnsIdentical();
                }

                for (int i = 0; i < _parentKey.ColumnsReference.Length; i++)
                {
                    if ((_parentKey.ColumnsReference[i].DataType != _childKey.ColumnsReference[i].DataType) ||
                        ((_parentKey.ColumnsReference[i].DataType == typeof(DateTime)) &&
                        (_parentKey.ColumnsReference[i].DateTimeMode != _childKey.ColumnsReference[i].DateTimeMode) &&
                        ((_parentKey.ColumnsReference[i].DateTimeMode & _childKey.ColumnsReference[i].DateTimeMode) != DataSetDateTime.Unspecified)))
                    {
                        // allow unspecified and unspecifiedlocal
                        throw ExceptionBuilder.ColumnsTypeMismatch();
                    }
                }
            }
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Does verification on the table.
        /// An ArgumentNullException is thrown if this relation is null.  An ArgumentException is thrown if this relation
        ///  already belongs to this collection, belongs to another collection.
        /// A DuplicateNameException is thrown if this collection already has a relation with the same
        /// name (case insensitive).
        /// </summary>
        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++;
            }
        }
All Usage Examples Of System.Data.DataRelation::CheckState