Exemplo n.º 1
0
 private void AddUniqueConstraint(UniqueConstraint constraint)
 {
     DataColumn[] columnsReference = constraint.ColumnsReference;
     for (int i = 0; i < columnsReference.Length; i++)
     {
         if (columnsReference[i].Table != this.table)
         {
             throw ExceptionBuilder.ConstraintForeignTable();
         }
     }
     constraint.ConstraintIndexInitialize();
     if (!constraint.CanEnableConstraint())
     {
         constraint.ConstraintIndexClear();
         throw ExceptionBuilder.UniqueConstraintViolation();
     }
 }
        private void AddUniqueConstraint(UniqueConstraint constraint)
        {
            DataColumn[] columns = constraint.Columns;

            for (int i = 0; i < columns.Length; i++)
            {
                if (columns[i].Table != this.table)
                {
                    throw ExceptionBuilder.ConstraintForeignTable();
                }
            }

            constraint.Key.GetSortIndex().AddRef();

            if (!constraint.CanEnableConstraint())
            {
                constraint.Key.GetSortIndex().RemoveRef();
                throw ExceptionBuilder.UniqueConstraintViolation();
            }
        }