Hi,
Apologies for what is no doubt a newbie question - I have searched and found two threads here and here. However, they have not helped me solve my problem. In theory, my problem is more or less identical to the first link.
I have two tables, Apartment and ApartmentType:
Apartment has
intApartmentID int primary key
intApartmentType int foreign key
vchApartmentName varchar
ApartmentType has
intApartmentType int primary key
vchApartmentType varchar
So, I want to get a collection of Apartments, deeploading the ApartmentType. I know that a record exists for IntApartmentID=6, I have ensured that the record in question has an existing record as its foreign key.
( edited for brevity)
TList<Apartment> aptList = DataRepository.ApartmentProvider.Find("IntApartmentID=6");
DataRepository.ApartmentProvider.DeepLoad(aptList, true, DeepLoadType.IncludeChildren, new Type[ { typeof(TList<ApartmentType>) });
Response.Write(aptList[0].VchName + "<br />");
Response.Write(aptList[0].IntApartmentTypeId + "<br />");
Response.Write(aptList[0].IntApartmentTypeIdSource.VchApartmentType); // <-- Error is thrown by this line
This results in "System.NullReferenceException: Object reference not set to an instance of an object." If I comment out the line, I can access the name and type.
I have also tried
DataRepository.ApartmentProvider.DeepLoad(aptList, true,
DeepLoadType.IncludeChildren,
typeof(TList<ApartmentType>) );
and
DataRepository.ApartmentProvider.DeepLoad(aptList, true,
DeepLoadType.IncludeChildren,
typeof(ApartmentType) );
(the last, as it is a 1-->1 relationship)
In each case, the IntApartmentTypeIdSource.VchApartmentType is null.
Coudl someone show me the error of my ways?
Thanks,
Anthony
* apologies for Hungarian notation, it is what I am used to- but it doesnt seem to fit .netTiers so well!