Updating FK

Posts   
 
    
Bruce
User
Posts: 61
Joined: 18-May-2006
# Posted on: 21-May-2006 19:42:35   

Using Vs2005, SQLServer2000, LLBLGenPro, SelfServiceing, TwoClass

I have a 1:n scenario where the collections are AgeGrpSys(1) and AgeGrp (m).

AgeGrpSys has PK AgeGrpSysID. AgeGrp has a composite PK of AgeGrpSysID and AgeGrpCode. These are all Integers. The tables are related on AgeGrpSysID.

I have a form containing a text box for the name of the AgeGrpSys and a DataGrid for AgeGrp.

I have a BindingNavigator to cycle through AgeGrpSys.

I found that to make it possible to add AgeGrp to a new AgeGrpSys I had to change the relationship between the two tables to Update-Cascade in the underlying db, Refresh the Catalog and reGenerate.

Afterwards I could set the Update-Cascade off in the database and the code still worked.

Is there a way to get this to work without setting the Update-Cascade at all?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 22-May-2006 11:21:53   

Update - cascade is that when the PK side (agegrpsys) has a changed PK, the FK fields are updated with that new value. However in your situation, that's not the case. You simply add a new AgeGrp entity to the collection of AgeGrp's, or am I wrong?

Be aware that changing the PK value of an AgeGrp entity, it effectively means you're removing the current entity and adding a new one.

Frans Bouma | Lead developer LLBLGen Pro
Bruce
User
Posts: 61
Joined: 18-May-2006
# Posted on: 22-May-2006 18:11:48   

Yes that is what Update-Cascade means.

Today I've done some testing of generating code with and without Update-Cascade on and comparing the results. I'm fairly sure that Update-Cascade has no effect on the code generation.

I must have done something wrong in my first code generation - possibly used the wrong configuration.

The main thing is that my code is working.

Thanks for your reply.