Multiple Relations and Predicate

Posts   
 
    
Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 13-Dec-2006 00:30:56   

I'm drawing a blank on this one.

I have a table 'Item', which has multiple related fields related to table 'Lookup'. When I add more than one relation to the Lookup table to my predicate bucket and then add one or more predicates that use Lookup related fields, they all default to the first relation.

For example


IRelationPredicateBucket bucket = new RelationPredicateBucket();

bucket.PredicateExpression.Add(predicate1);
bucket.PredicateExpression.Add(predicate2);
bucket.PredicateExpression.Add(predicate3);

bucket.Relations.Add(ItemEntity.Relations.LookupEntityUsingGraphicsContactID, JoinHint.Left);
bucket.Relations.Add(ItemEntity.Relations.LookupEntityUsingMarketingContactID, JoinHint.Left);
bucket.Relations.Add(ItemEntity.Relations.LookupEntityUsingMarketSegmentID, JoinHint.Left);


In this example I would want predicate1 to use the first relationship, predicate2 to use the second, etc.

How is this possible? Is this possible?

Edit: This should probably go in generated code, sorry flushed

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 13-Dec-2006 03:18:26   

You will need to use aliases so that the correct relationships are used with the correct predicates. Here's an example.


IRelationPredicateBucket bucket = new RelationPredicateBucket();

bucket.PredicateExpression.Add(TestFields.TestName.SetObjectAlias("First") == "FirstText");
bucket.PredicateExpression.Add(TestFields.TestName.SetObjectAlias("Second") == "SecondText");

bucket.Relations.Add(ItemEntity.Relations.LookupEntityUsingGraphicsContactID, "First", JoinHint.Left);
bucket.Relations.Add(ItemEntity.Relations.LookupEntityUsingGraphicsContactID, "Second", JoinHint.Left);

Cadmium avatar
Cadmium
User
Posts: 153
Joined: 19-Sep-2003
# Posted on: 13-Dec-2006 05:42:28   

Perfect! Thank you so much!