Export (0) Print
Expand All

ForeignKeyConstraint.Equals Method (Object)

Gets a value indicating whether the current ForeignKeyConstraint is identical to the specified object.

Namespace: System.Data
Assembly: System.Data (in system.data.dll)

public override bool Equals (
	Object key
)
public boolean Equals (
	Object key
)
public override function Equals (
	key : Object
) : boolean

Parameters

key

The object to which this ForeignKeyConstraint is compared. Two ForeignKeyConstraint are equal if they constrain the same columns.

Return Value

true, if the objects are identical; otherwise, false.

The following example creates a new ForeignKeyConstraint and checks it against other collection members with the Equals method before adding it to a ConstraintCollection.

private void CreateConstraint(DataSet dataSet)
{
   // Create the ForignKeyConstraint with two DataColumn objects.
   DataColumn parentCol = dataSet.Tables["Customers"].Columns["id"];
   DataColumn childCol = dataSet.Tables["Orders"].Columns["OrderID"];
   ForeignKeyConstraint fkeyConstraint =
      new ForeignKeyConstraint("fkConstraint", parentCol, childCol);

   // Test against existing members using the Equals method.
   foreach(ForeignKeyConstraint testConstraint in 
       dataSet.Tables["Orders"].Constraints)
   {
      if(fkeyConstraint.Equals(testConstraint)){
         Console.WriteLine("Identical ForeignKeyConstraint!");
          // Insert code to delete the duplicate object, 
          // or stop the procedure.
      
   


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft