Problem with TestCurrentFieldValueForNull

Posts   
 
    
aker
User
Posts: 1
Joined: 18-Nov-2005
# Posted on: 18-Nov-2005 05:52:52   

Hi,

When i create a new entity, set the value of a field to null, and test it with TestCurrentFieldValueForNull, i get false. To get true i must save the new entity and retrieve it again from the Db.

My code is very similar to the one in the documentation:

CustomerEntity customer = new CustomerEntity(); customer.SetNewFieldValue((int)CustomerFieldIndex.ContactTitle, null); customer.TestCurrentFieldValueForNull(CustomerFieldIndex.ContactTitle); // Doesn't return true!!!

Thanks in advance, Leo

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39618
Joined: 17-Aug-2003
# Posted on: 18-Nov-2005 10:40:17   

Indeed, I can reproduce this. If you don't set the field to null explicitly it works, but if you set it explicitly to null it doesn't. As with a new entity, a field is null (or undefined) by default unless you set it to a value explicitly, so the explicit set for null is unnecessary in this context, but nevertheless it should work.

So as a workaround till this is fixed: remove the SetNewFieldValue line, it's not required for a new entity.

(edit) fixed in next build. If you remove the SetNewFieldValue(..., null) from your code it works. That particular line makes teh code fail. The test routine checks if the entity is new, and if so it will return true if the field isn't changed. So as long as you don't set a NEW entity's field to null explicitly (which you don't have to do anyway), you're fine. Use that as a workaround till the fix is available.

Frans Bouma | Lead developer LLBLGen Pro