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
- key
- The object to which this ForeignKeyConstraint is compared. Two ForeignKeyConstraint are equal if they constrain the same columns.
This method returns only a boolean value: true, if the objects are identical; otherwise, false.
The property is read only with no default value.
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.
}
}
}
ForeignKeyConstraint Members