What is the action of ForeinKeyConstraint.AcceptRule = Cascade - Ado.net 2.0

R

Rolf Welskes

Hello,
I have understand all about ForeignKeyConstraint .

But:
When I set

ForeignKeyConstraint.AcceptRule = AcceptRejectRule.None
or
ForeignKeyConstraint.AcceptRule = AcceptRejectRule.Cascade

I see no difference in behavor.

What is the difference (not what you can read in the help),
but what realy is the action wich takes place when I set to Cascade.

Thank you for any help.
Best Regards
Rolf Welskes
 
W

WenYuan Wang

Hi Rolf,

I think what you mentioned about is the "AcceptRejectRule" property of
ForeignKeyConstraint. If I misunderstood anything, please don't hesitate to
correct me.
AcceptRejectRule is used when AcceptChanges() method called or
RejectChanges() method called. When either AcceptChanges or RejectChanges
is called on a row in the parent table, the AcceptRejectRule value
determines whether or not changes are propagated to corresponding rows in
the child table.
For example:
You deleted a row in Table_1, at the same time, the related rows in Table_2
will also be deleted.(if the DeleteRule is set to Rule.Cascade).
The state for each row is "deleted", and then you call
Table_1.AcceptChanges() method.
#1(AcceptRejectRule =AcceptRejectRule.None): Nothing will happen in Table_2;
#2(AcceptRejectRule =AcceptRejectRule.Cascade): the state of related rows
in Table_2 will be changed.

Hope this will help. Please feel free to let me know if you have anything
unclear and we will follow up.
Best regards,
Wen Yuan
 
R

Rolf Welskes

Hello,
thank you for your informations.
It works fine.
Thank you again and best regards
Rolf Welskes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top