TestCurrentFieldValueForNull and Nullable values

Posts   
 
    
Posts: 14
Joined: 06-Feb-2007
# Posted on: 05-Jul-2007 14:41:59   

Hi,

I have a collection of persons. Person.DateOfDecease is NULLABLE. LLBLGen v.2, used the plugin to avoid the System.Nullable types.

I create a new Person, which makes a new Entity too.

m_dateOfDeceaseDefined = ! m_personEntity.TestOriginalFieldValueForNull(PersonFieldIndex.DateOfDecease);

m_personEntity.DateOfDecease shows as DateTime.MinValue... ok. But TestOriginalFieldValueForNull doesn't see it as NULL, so the bool is set to TRUE. When persisted, the value in the database is NULL.

I really fail to see logic in there. While I do understand that a default value is shown (DateTime.MinValue), imho the TestOriginalFieldValueForNull should take that into account. DateOfDecease IS null, but my Person will claim otherwise when I poll the bool.

It's a redundant question, I know... but can I please get some feedback on this?

Thanks,

Koen

edit Was there similar behaviour in version 1.2005 of LLBLGen? /edit

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Jul-2007 15:14:44   

TestOriginalFieldValueForNull doesn't see it as NULL, so the bool is set to TRUE.

Do you run this check on a fetched entity?

Posts: 14
Joined: 06-Feb-2007
# Posted on: 05-Jul-2007 15:42:53   

Hi walaa,

thanks for your help.

I took a look and it behaves correct on existing entities. When I create a new one, it returns true. My humble guess: I should use "TestCurrentFieldValueForNull" in new entities rather then "TestOriginalFieldValueForNull"?

Thanks,

Koen

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 05-Jul-2007 16:07:48   

Exactly, as the originalFieldValue, is the last value fetched from the database.