How do I save all Entities in a 1:1 relation

Posts   
 
    
chaimweb
User
Posts: 10
Joined: 12-Apr-2005
# Posted on: 31-May-2005 16:13:07   

I have 2 tables that are in a 1:1 relationship. Table1 - empID PK, GovID Table2 - empID FK, ... I managed to fetch a Table2Entity and bind all its fileds to the textboxes on a form, including the GovID field form Table1 by adding it as a "Fields on related fields" in the Table2Entity in the Designer. However, when saving newly added Table2Entity, the Table1 fields are not inserted in Table1? Another issue on saving came up when changing fields in an Entity that is related via another related table, the related table was not updated. eg: Tbl1: EmpID Tbl2: CompanyID, Cyname Tbl3: EmpID, CompanyID - an m:n relation When fetching a Tbl1Entity, the related Tbl2Entity (via Tbl3) was fetched, but the changes were not updated in the database. I used SaveMulti(true) inboth instances.

thanks, Chaim

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 31-May-2005 20:49:00   

If you edit entities in an m:n relation, these aren't saved, as the m:n relation is read-only. Please edit the entities via teh intermediate entity, then changes are saved.

Frans Bouma | Lead developer LLBLGen Pro
chaimweb
User
Posts: 10
Joined: 12-Apr-2005
# Posted on: 01-Jun-2005 12:25:52   

What about the second issue - saving a field of type "fields on related fields" in my orig. msg ?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 01-Jun-2005 23:18:24   

chaimweb wrote:

I have 2 tables that are in a 1:1 relationship. Table1 - empID PK, GovID Table2 - empID FK, ... I managed to fetch a Table2Entity and bind all its fileds to the textboxes on a form, including the GovID field form Table1 by adding it as a "Fields on related fields" in the Table2Entity in the Designer. However, when saving newly added Table2Entity, the Table1 fields are not inserted in Table1?

Did you add a new Table1 to the new table2 entity? You have to, before binding the table2 instance to the properties.

Another issue on saving came up when changing fields in an Entity that is related via another related table, the related table was not updated. eg: Tbl1: EmpID Tbl2: CompanyID, Cyname Tbl3: EmpID, CompanyID - an m:n relation When fetching a Tbl1Entity, the related Tbl2Entity (via Tbl3) was fetched, but the changes were not updated in the database. I used SaveMulti(true) inboth instances. thanks, Chaim

The second issue is about the m:n relations being used in a read-only manner.

Frans Bouma | Lead developer LLBLGen Pro