asp.net.ph

ForeignKeyConstraint.Equals Method

ForeignKeyConstraint Class   System.Data Namespace


Checks whether the current ForeignKeyConstraint is identical to the specified object.

[ VB ]
Overrides Public Function Equals ( _
   ByVal key As Object _
) As Boolean

[ C# ]
public override bool Equals (
   object key
);

[ C++ ]
public: bool Equals (
   Object* key
);

[ JScript ]
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

This method returns only a boolean value: true, if the objects are identical; otherwise, false.

The property is read only with no default value.

Example

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

private void CreateConstraint ( DataSet myDataSet ) {
   // create the ForignKeyConstraint with two DataColumn objects.
   DataColumn parentCol = myDataSet.Tables [ "Customers" ].Columns [ "id" ];
   DataColumn childCol = myDataSet.Tables [ "Orders" ].Columns [ "OrderID" ];
   ForeignKeyConstraint fKeyConstraint  = 
      new ForeignKeyConstraint ( "MyConstraint", parentCol, childCol );
   // test against existing members using the Equals method.
   foreach ( ForeignKeyConstraint fcstr in DataSet.Tables [ "Orders" ].Constraints ) {
      if ( fKeyConstraint.Equals ( fcstr ) {
         Response.Write ( "identical ForeignKeyConstraint!" );
         //Insert code to delete the identical object, or stop the procedure.
     }
   }
}
See Also

ForeignKeyConstraint Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph