System.Data.ForeignKeyConstraint.CanEnableConstraint C# (CSharp) Method

CanEnableConstraint() private method

private CanEnableConstraint ( ) : bool
return bool
        internal override bool CanEnableConstraint()
        {
            if (Table.DataSet == null || !Table.DataSet.EnforceConstraints)
            {
                return true;
            }

            Index childIndex = _childKey.GetSortIndex();
            object[] uniqueChildKeys = childIndex.GetUniqueKeyValues();

            Index parentIndex = _parentKey.GetSortIndex();
            for (int i = 0; i < uniqueChildKeys.Length; i++)
            {
                object[] childValues = (object[])uniqueChildKeys[i];

                if (!IsKeyNull(childValues) && !parentIndex.IsKeyInIndex(childValues))
                {
                    return false;
                }
            }
            return true;
        }

Usage Example

Exemplo n.º 1
0
 private void AddForeignKeyConstraint(ForeignKeyConstraint constraint)
 {
     if (!constraint.CanEnableConstraint())
     {
         throw ExceptionBuilder.ConstraintParentValues();
     }
     constraint.CheckCanAddToCollection(this);
 }
All Usage Examples Of System.Data.ForeignKeyConstraint::CanEnableConstraint