Entity Collection and 1:1 relation

Posts   
 
    
PeterJ
User
Posts: 6
Joined: 06-May-2008
# Posted on: 20-Jun-2008 19:04:07   

Hi,

Apologies if this is simplistic, I'm just starting out on LLBLGen... simple_smile

I have a DB structure

Account table

AccountId (PK) ContractTypeId (from below) ... various other columns

Address table

AddressId RelationId (will be AccountId in this example, but can be others) ... various other columns

ContractType table

ContractTypeId Description

Account to Address is defined 1:n Account to ContractType as 1:1 in LLBLGen

I can get an EntityCollection<AccountEntity> with the AddressEntity collection, but not the ContractType. This is the code (omitting the try-catch, .Net2):


EntityCollection<AccountEntity> accounts = null;
IPrefetchPath2 prefetchPath = new PrefetchPath2( (Int32)EntityType.AccountEntity );
prefetchPath.Add( AccountEntity.PrefetchPathContractType );
prefetchPath.Add( AccountEntity.PrefetchPathAddresses );

using ( DataAccessAdapter adaptor = new DataAccessAdapter() )
{
    accounts = customer.Accounts; // customer entity defined previously
    adaptor.FetchEntityCollection( accounts, customer.GetRelationInfoAccounts(), prefetchPath );
}

But AccountEntity.ContractType remains null.

Am I making some mistake here?

Rgds, Peter

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Jun-2008 05:05:17   

PeterJ wrote:

Account table

AccountId (PK) ContractTypeId (from below) ... various other columns

Address table

AddressId RelationId (will be AccountId in this example, but can be others) ... various other columns

ContractType table

ContractTypeId Description

Account to Address is defined 1:n Account to ContractType as 1:1 in LLBLGen

Hi Peter, I don't get how Account--ContractType relation could be 1:1 disappointed What is the ContractType's PK, and the FK to Account?

PeterJ wrote:

I can get an EntityCollection<AccountEntity> with the AddressEntity collection, but not the ContractType. This is the code (omitting the try-catch, .Net2) ... But AccountEntity.ContractType remains null.

First of all, are you sure that the Account you are testing have a ContractType related?

Also please post: - Exact exception message and stack trace - LLBLGen version and RuntimeLibrary version (ref...).

David Elizondo | LLBLGen Support Team
PeterJ
User
Posts: 6
Joined: 06-May-2008
# Posted on: 23-Jun-2008 15:34:48   

daelmo wrote:

Hi Peter, I don't get how Account--ContractType relation could be 1:1 disappointed What is the ContractType's PK, and the FK to Account?

I shouldn't do these things late on a Friday. Your question made me realise there was an error in the design I did. Should be a m:1.

All works now.

Thanks, Peter