[SOLVED] SetNewFieldValue and FK

Posts   
 
    
taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 04-Dec-2004 04:13:30   

Hi everybody, I'm new around here. Been working with the product for a couple of weeks now. LLBLGen is the best O/R Mapper I have found. Words can't express how good it is compared to others on the market.

I think I have come across a little bug, though.

From the documentation:

If you set a foreign key field (for example Order.CustomerID) to a new value, the referenced entity by the foreign key (relation) the field is part of will be dereferenced and the field mapped onto that relation is set to null (C#) or Nothing (VB.NET).

That works when I do entityInstance.FKID = some integer number, but if I want my FK to be null in the database, I use entityInstance.SetNewFieldValue to set it to Nothing. The FK does get set to null in the database when the entity is saved.

The problem I am experiencing is that the referenced entity for the foreign key is not dereferenced and set to Nothing when I use the SetNewFieldValue method.

Is this a bug or intended functionality? BTW, I'm using Adapter.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Dec-2004 11:45:47   

taylor74 wrote:

Hi everybody, I'm new around here. Been working with the product for a couple of weeks now. LLBLGen is the best O/R Mapper I have found. Words can't express how good it is compared to others on the market.

smile

I think I have come across a little bug, though. From the documentation:

If you set a foreign key field (for example Order.CustomerID) to a new value, the referenced entity by the foreign key (relation) the field is part of will be dereferenced and the field mapped onto that relation is set to null (C#) or Nothing (VB.NET).

That works when I do entityInstance.FKID = some integer number, but if I want my FK to be null in the database, I use entityInstance.SetNewFieldValue to set it to Nothing. The FK does get set to null in the database when the entity is saved.

The problem I am experiencing is that the referenced entity for the foreign key is not dereferenced and set to Nothing when I use the SetNewFieldValue method. Is this a bug or intended functionality? BTW, I'm using Adapter.

This is unforeseen behavior. The property contains the logic to dereference the related entity, SetNewFieldValue() is located in the base class. I'll try to fix this, but it won't be easy. THanks for reporting simple_smile

Frans Bouma | Lead developer LLBLGen Pro
taylor74
User
Posts: 59
Joined: 06-Oct-2004
# Posted on: 04-Dec-2004 22:09:04   

This is unforeseen behavior. The property contains the logic to dereference the related entity, SetNewFieldValue() is located in the base class. I'll try to fix this, but it won't be easy. THanks for reporting

Not a big deal. After using SetNewFieldValue I just dereference the releated entity manually. There's nothing I should be concerned about in doing that is there?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 04-Dec-2004 22:42:46   

No that's perfectly fine simple_smile

Frans Bouma | Lead developer LLBLGen Pro