System.Data.ForeignKeyConstraint.Equals C# (CSharp) Метод

Equals() публичный Метод

Gets a value indicating whether the current is identical to the specified object.
public Equals ( object key ) : bool
key object
Результат bool
        public override bool Equals(object key)
        {
            if (!(key is ForeignKeyConstraint))
            {
                return false;
            }
            ForeignKeyConstraint key2 = (ForeignKeyConstraint)key;

            // The ParentKey and ChildKey completely identify the ForeignKeyConstraint
            return ParentKey.ColumnsEqual(key2.ParentKey) && ChildKey.ColumnsEqual(key2.ChildKey);
        }

Usage Example

Пример #1
0
		[Test] public void Equals()
		{
			DataSet ds = new DataSet();
			DataTable dtParent = DataProvider.CreateParentDataTable();
			DataTable dtChild = DataProvider.CreateChildDataTable();
			ds.Tables.Add(dtParent);
			ds.Tables.Add(dtChild);
			dtParent.PrimaryKey = new DataColumn[] {dtParent.Columns[0]};
			ds.EnforceConstraints = true;

			ForeignKeyConstraint fc1,fc2;
			fc1 = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]);

			fc2 = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[1]);
			// different columnn
			Assert.AreEqual(false, fc1.Equals(fc2), "FKC3");

			//Two System.Data.ForeignKeyConstraint are equal if they constrain the same columns.
			// same column
			fc2 = new ForeignKeyConstraint(dtParent.Columns[0],dtChild.Columns[0]);
			Assert.AreEqual(true, fc1.Equals(fc2), "FKC4");
		}
All Usage Examples Of System.Data.ForeignKeyConstraint::Equals