Relation Alias Issues

Posts   
 
    
jyoung
User
Posts: 33
Joined: 27-Feb-2006
# Posted on: 01-Dec-2006 21:34:43   

I keep getting “Relation at index 2 doesn't contain an entity already added to the FROM clause. Bad Alias?” error. Is there any way to determine what the bad alias is and why it is bad?

I can get this to work:


predicateBucket.Relations.Add(ProductEntity.Relations.StringGroupEntityUsingNameStringId, nameGroupAlias);
predicateBucket.Relations.Add(StringGroupEntity.Relations.StringItemEntityUsingStringGroupId, nameGroupAlias, nameAlias, JoinHint.Inner);

However when I add this:


customerCatalogPredicate.Add(CustomerCatalogFields.CatalogId == parameters.CatalogId);

predicateBucket.Relations.Add(CustomerCatalogEntity.Relations.CustomerCatalogProductEntityUsingCustomerCatalogId).CustomFilter = customerCatalogPredicate;
predicateBucket.Relations.Add(CustomerCatalogProductEntity.Relations.ProductEntityUsingProductId);

I get the Bad Alias at index 2 message.

I have tried adding a product alias onto the Product and CustomerCatalogProduct relations but that does not seem to work either.

I am using the July 6th 2006 release of 1.0.2005.1.

Thanks in advance,

Joe

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 02-Dec-2006 10:20:52   

They're processed from front to back. You should first add the product relation. So instead of:


customerCatalogPredicate.Add(CustomerCatalogFields.CatalogId == parameters.CatalogId);
predicateBucket.Relations.Add(CustomerCatalogEntity.Relations.CustomerCatalogProductEntityUsingCustomerCatalogId).CustomFilter = customerCatalogPredicate;
predicateBucket.Relations.Add(CustomerCatalogProductEntity.Relations.ProductEntityUsingProductId);

do:


predicateBucket.Relations.Add(CustomerCatalogProductEntity.Relations.ProductEntityUsingProductId);
customerCatalogPredicate.Add(CustomerCatalogFields.CatalogId == parameters.CatalogId);
predicateBucket.Relations.Add(CustomerCatalogEntity.Relations.CustomerCatalogProductEntityUsingCustomerCatalogId).CustomFilter = customerCatalogPredicate;

Frans Bouma | Lead developer LLBLGen Pro