Exemple #1
0
        internal static UniqueConstraint GetUniqueConstraintForColumnSet(ConstraintCollection collection,
                                                                         DataColumn[] columns)
        {
            if (null == collection)
            {
                throw new ArgumentNullException("Collection can't be null.");
            }
            if (null == columns)
            {
                return(null);
            }

            foreach (Constraint constraint in collection)
            {
                if (constraint is UniqueConstraint)
                {
                    UniqueConstraint uc = constraint as UniqueConstraint;
                    if (DataColumn.AreColumnSetsTheSame(uc.Columns, columns))
                    {
                        return(uc);
                    }
                }
            }
            return(null);
        }
Exemple #2
0
        public override bool Equals(object key2)
        {
            UniqueConstraint cst = key2 as UniqueConstraint;

            if (null == cst)
            {
                return(false);
            }

            //according to spec if the cols are equal
            //then two UniqueConstraints are equal
            return(DataColumn.AreColumnSetsTheSame(cst.Columns, this.Columns));
        }
        public override bool Equals(object key)
        {
            ForeignKeyConstraint fkc = key as ForeignKeyConstraint;

            if (null == fkc)
            {
                return(false);
            }

            //if the fk constrains the same columns then they are equal
            if (!DataColumn.AreColumnSetsTheSame(this.RelatedColumns, fkc.RelatedColumns))
            {
                return(false);
            }
            if (!DataColumn.AreColumnSetsTheSame(this.Columns, fkc.Columns))
            {
                return(false);
            }

            return(true);
        }