creating an entity consisting of 2 tables.

Posts   
 
    
scf
User
Posts: 5
Joined: 14-Dec-2006
# Posted on: 14-Dec-2006 13:05:29   

Hello!

I have two objects: employee and contract. They are 1:1 related. Contract has a field ContractTypeId, which references to ContractTypes table. FormView is bound to a llblgen datasource with entitytype employee. Employee has a field on relation property ContractTypeId. So in the FormView I can edit the fields of an employee themself and select a contract type in a dropdownlist. Updating existing employee works fine, but when I try to create a new one - I get a error that ContractTypeId in the table Contract can't be null. The way I want it to work is when I create a new employee a new records is added to employee and to contract tables. Seems it "tries" to work that way, but inserts a null somewhy into the ContractTypeId column (I've tried to debug it and found that the property ContractTypeId of the Contract object is set to right value). Is it possible to do?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Dec-2006 14:34:01   

Turn LivePersistence off (A property of the LLBLGenProDataSource control) And do the saving work yourself using the PerformWork event.

In that case you will create an Employee entity, attach a contract entity to it with the selected contractTypeId.

please refer to the LLBLGen Pro docs "Using the generated code -> Adapter/SelfServicing -> Databinding with ASP.NET 2.0"

Check the section: LivePersistence and events

scf
User
Posts: 5
Joined: 14-Dec-2006
# Posted on: 14-Dec-2006 14:40:23   

Sad to hear that rage I have the project working fine with livepersistance on, and only the described issue prevents from finishing it. I wanted to avoid the big changes.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 14-Dec-2006 16:00:46   

You could set the livepersistence off for just this datasource, it doesn't take more than a few lines to get this working in the code behind. Then you can keep all other datasources on livepersistence is true and this datasource on livepersistence = false.

Frans Bouma | Lead developer LLBLGen Pro
scf
User
Posts: 5
Joined: 14-Dec-2006
# Posted on: 18-Dec-2006 10:16:51   

It's not that easy in my case because of custom templating. But as I don't have other solution I'll try to make it work the way you described. Thank you.