filter on EntityCollection ?

Posts   
 
    
alexshull
User
Posts: 5
Joined: 28-Aug-2007
# Posted on: 28-Aug-2007 00:50:59   

LLBLGen v2.0, Adapter, .Net 2.0

How can I use an EntityCollection to filter a subsequent query? Something along these lines is what I am after:

public class SoAreas: EntityCollection<SoAreaEntity> {}

public class SalesGoals:EntityCollection<SoAreaSalesGoalsEntity> { public SalesGoals GetSalesGoals(DateTime beginDate, DateTime endDate, SoAreas divisions) { SalesGoals returnGoals = new SalesGoals(); SoAreaSalesGoalsRelations relations = new SoAreaSalesGoalsRelations();

  RelationPredicateBucket filter = new RelationPredicateBucket();
  filter.Relations.Add(relations.SoAreaEntityUsingSoareaid);
  filter.PredicateExpression.Add(SoAreaSalesGoalsFields.BeginDate >= beginDate);
  filter.PredicateExpression.AddWithAnd(SoAreaSalesGoalsFields.EndDate <= endDate);
  filter.PredicateExpression.Add(SoAreaFields.Id IN **divisions**);
  DataAccessAdapter daa = new DataAccessAdapter();
  daa.FetchEntityCollection(returnGoals, filter);
  return returnGoals;
}

}

Is there any way to filter against an entity collection like this?

Thanks for your help.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Aug-2007 05:19:09   

Hi Alex,

You can't do that in such way, so the predicate system wouldn't know against which collection's field compare (http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=9996).

However you could construct an array of values, then filter on it simple_smile :

System.Collections.ArrayList values = new System.Collections.ArrayList();
foreach (SoAreaEntity sae in divisions)
{
    values.Add(sae.Id);
}

filter.PredicateExpression.Add(SoAreaFields.Id == values);

For more info read LLBLGenPro Help - Using the generated code - Adapter - Filtering and Sorting - The predicate system - FieldCompareRangePredicate.

David Elizondo | LLBLGen Support Team
alexshull
User
Posts: 5
Joined: 28-Aug-2007
# Posted on: 28-Aug-2007 15:35:13   

Thanks for the reply. I know this method, and I can use that instead, though it's not really what I wanted. I thought it might be possible for this predicate to be parsed such that the ID property would be compared to the ID property of the collection members. I suppose this feature is not useful enough to bother including.