Readonly problem

Posts   
 
    
Rene
User
Posts: 54
Joined: 20-Jun-2006
# Posted on: 21-Jun-2006 10:07:17   

Hi,

I have an existing database-structure and I need to implement an LLBLGen project on top of it. There is a parent-table and a child-table. Both tables have an Identity-field. But the actual key-fields in the parent-table are different. There is a set of two fields, in the parent-table, which have a unique combination of values, which are determined by the application (not by SQL Server). The child-table has a link to the parent-table. But it does not link to the identity-field of the parent-table. Instead, there are two fields, which refer to the unique fields in the parent-table.

I created an LLBLGen-project, based on these tables. I made the two unique fields in the parent-entity 'part of the primary key' (so these are not the identity-field). Then I created a relation between these entities and I let the two fields in child-entity refer to the primary-key fields of the parent-entity. This works fine.

The problem arises when I try to populate some entities with data, in order to update the information in the database. The information has been kept in memory and is now stored back to an entity, so it has not been fetched in the entity. When I try to populate the entity, the identity-field of the parent-entity is readonly. If I don't set the identity-field, a new record will be created in the database. Instead, I want to update an existing record. I want to avoid reading the entity from the database, because I got everything already in memory.

General info: Using latest version of LLBLGen 1.0.2005.1 designer and runtimes. Adapter-scenario. VS 2005. .NET 2.0.

Is there anyway I achieve this? Please suggest. Thanks! René

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39928
Joined: 17-Aug-2003
# Posted on: 21-Jun-2006 10:26:15   

use entity.Fields[(int)EntityFieldIndex.IdentityField].ForcedCurrentValueWrite(value);

wink

This won't set IsChanged, so it just sets the value.

Frans Bouma | Lead developer LLBLGen Pro
Rene
User
Posts: 54
Joined: 20-Jun-2006
# Posted on: 21-Jun-2006 11:32:06   

I found another work-around. I removed the 'identity'-flag in sql-server. I refreshed the catalog in llblgen. I could then remove the readonly-flag of that field in llblgen. I added the 'identity'-flag again in sql server. I refreshed the catalog again and then I got my identity-field with readonly-flag unchecked in llblgen.

But your solution is much easier wink Thanks for another quick reply!

René