populate intermediate entities automatically?

Posts   
 
    
Posts: 6
Joined: 07-Nov-2008
# Posted on: 08-Nov-2008 00:50:33   

Hi there,

thanks for the reply, but the example you pointed me to doesn't work in my senario:

to Recap:

I need to populate an intermediate entity.

I have a UniversityLocation Entity (all FKs populated) I have a ZipCode Entity (no FKs)

and I need to populate the intermediate entity UniversityLocationZipCode, which has it's own PK, and the FKs from UniversityLocation and ZipCode.

(please see the attched schema screenshot)

I tried the following code:

UniversityLocationZipCodeEntity univLocZipCodeEnt = new UniversityLocationZipCodeEntity(); univLocZipCodeEnt.UniversityLocation = UniversityLocation; univLocZipCodeEnt.ZipCode = zipCode; univLocZipCodeEnt.Save(true);

the error that this code produced says I cannot create the intermediate entity: UniversityLocationZipCodeEntity because it can't find the universitylocationid in the UniversityLocationEntity... but my UniversityLocationEntity does indeed have a universitylocationID....

Must I instead use code like the following and explicitly supply the FKs?

UniversityLocationZipCodeEntity univLocZipCodeEnt = new UniversityLocationZipCodeEntity(); univLocZipCodeEnt.Universitylocationid = UniversityLocation.Universitylocationid; univLocZipCodeEnt.Zipcodeid = zipCode.Zipcodeid; univLocZipCodeEnt.Save(true);

thanks, Dustin

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 08-Nov-2008 05:39:52   
David Elizondo | LLBLGen Support Team