Setting GUIDs to null...

Posts   
 
    
Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 15:27:21   

CType(_CaseEntity.Applicants.Items(_ApplicantSelectedIndex), EntityClasses.CaseApplicantEntity).SetNewFieldValue("BankId", Nothing)

This causes a null exception..

however, doing the same thing with a date datatype works fine.

Is this a problem with GUIDs or just my code.

Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 15:31:21   

Exception Source: SD.LLBLGen.Pro.ORMSupportClasses.NET11 Exception Type: System.NullReferenceException Exception Message: Object reference not set to an instance of an object. Exception Target Site: SetNewFieldValue

Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 15:32:54   

If step the code and do ... ? CType(_CaseEntity.Applicants.Items(_ApplicantSelectedIndex), EntityClasses.CaseApplicantEntity).BankId.ToString

I get the GUID returned, so there is currently a GUID set to that field.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 26-Oct-2005 15:54:42   

Please could you tell us what Runtime Library version you are using

Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 15:57:06   

1.0.2004.2, havent upgraded yet.

Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 15:58:49   

There is a M:1 relationship with Bank, however I do not bring the bank back with the prefetch for that entity.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Oct-2005 16:03:51   

The one time I saw this error there were no fields in the entity. GUIDs should be settable to null, that's not a problem. Could you check what the build is of the runtime libraries? rightclick on the ormsupportclasses dll -> properties (in windows explorer) and then version tab. It should say 1.0.20042.yymmdd

Frans Bouma | Lead developer LLBLGen Pro
Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 17:16:39   

1.0.20042.50923

Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 18:00:27   

Would there be a problem if I am trying to set it to NULL if it is already NULL?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Oct-2005 18:26:40   

Coolcoder wrote:

Would there be a problem if I am trying to set it to NULL if it is already NULL?

No, that would be a problem with an old runtime lib, but yours is pretty new, there are no bugs known related to setnewfieldvalue after that date.

So to be able to test what you're experiencing here, I have to verify if I understand the situatoin correctly: you have a single entity, which has an FK field, which is a GUID, and you load an instance of that entity and then set that FK field to nothing, by using the statement you quoted.

at the point you set the field to nothing, the related entity is NOT present? And because you're casting, I assume you're using adapter?

Frans Bouma | Lead developer LLBLGen Pro
Coolcoder
User
Posts: 37
Joined: 22-Sep-2005
# Posted on: 26-Oct-2005 20:55:01   

Indeed but the problem has now gone....

I think its related to the field being NULL to start off with, not sure - will do more testing.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 27-Oct-2005 12:31:23   

Coolcoder wrote:

Indeed but the problem has now gone....

I think its related to the field being NULL to start off with, not sure - will do more testing.

Ok, please post a repro case when you've done more testing so we can investigate the issue here simple_smile

Frans Bouma | Lead developer LLBLGen Pro