Grandchild relations in

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 03-Oct-2007 22:45:28   

I want to get a ProductCollection based on the value of grandchild values.

Using the code below, I can look up child values:

ProductCollection product = new ProductCollection(); RelationCollection relations = new RelationCollection(); relations.Add(ProductEntity.Relations.ProductTypeOptionAttributeCombinationEntityUsingProductId);

IPredicateExpression filter = new PredicateExpression(); filter.Add(_Child Field Value_);

product.GetMulti(filter, 0, null, relations);

But what do I do if I want to filter on a child of the ProductTypeOptionAttributeCombinationEntity?

Many thanks

Darren

P.S. Yeah I know I need to re-consider the name of that table and make it shorter!!! frowning

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Oct-2007 02:48:29   

Hi Darren,

You should add the Child <- GrandChild relation to the relation collection. After that you can add filter expressions based on GrandChild's fields.

example:

ProductCollection product = new ProductCollection();
RelationCollection relations = new RelationCollection();
// child
relations.Add(ProductEntity.Relations.ProductTypeOptionAttributeCombinationEntityUsingProductId);
// grandchild
relations.Add(ProductTypeOptionAttributeCombinationEntity.Relations.GrandChildEntityUsingSomeConnectionFieldId);

IPredicateExpression filter = new PredicateExpression();
filter.Add(Child Field Value);
filter.Add(GrandChild Field Value);

Regards,

David Elizondo | LLBLGen Support Team
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 04-Oct-2007 12:19:00   

Brilliant - thanks very much simple_smile

Got it working.