LoadProperty Null Guid FK

LoadProperty Null Guid FK

Old forum URL: forums.lhotka.net/forums/t/5843.aspx


greengumby posted on Thursday, November 20, 2008

CSLA : 3.5

Hi,

How do I handle Null Guid Foreign Key's  on a BusinessBase Data_Fetch method.

LoadProperty<Guid, Guid?>(FKYearProperty, data.FKYear);

I keep getting an error,

DataPortal.Fetch failed (DataPortal.Fetch failed Property load or set failed for property FKState (Null object cannot be converted to a value type.)))

I know its probably something simple but I am new to CSLA.

The Fetch is selecting the data using LINQ

Looking at the generated LINQ source I see this style

[Column(Storage="_FKYear", DbType="UniqueIdentifier")]

public System.Nullable<System.Guid> FKYear

Many thanks for your time and help

Jeremy

 

 

 

 

tetranz replied on Friday, November 21, 2008

Hi Jeremy,

I think your LoadProperty code is wrong.

LoadProperty<
Guid, Guid?>(FKYearProperty, data.FKYear);

should be

LoadProperty<Guid?>(FKYearProperty, data.FKYear);

I use nullables all the time with CSLA managed fields and they seem to work well.

greengumby replied on Tuesday, November 25, 2008

Thankyou very much. It worked perfectly.

 

 

Copyright (c) Marimer LLC