TypedLists and Predicates on the COUNT aggregated field

Posts   
 
    
Posts: 30
Joined: 17-Sep-2006
# Posted on: 09-Oct-2007 11:46:26   

I have a typed list with an aggregate field calculated using the COUNT operator (all defined in the designer). How can I specify a predicate in code indicating that I only want rows with a particular COUNT?

TagViewTypedList tagView = new TagViewTypedList(); IRelationPredicateBucket relations = tagView.GetRelationInfo(); relations.PredicateExpression.Add(MyTagViewCaculatedCountField > 0) ... adapter.FetchTypedList(tagView.GetFieldsInfo(), tagView, relations, ....)

is what I want to do... I've tried replacing MyTagViewCaculatedCountField with the field that it's actually counting, but that just adds a where clause on the field value itself (rather than the count of that field) - which is kinda what I'd expect.

Any ideas?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 09-Oct-2007 12:58:50   

Try something like:

IEntityFields2 tlFields = tagView.GetFieldsInfo();
relations.PredicateExpression.Add(tlFields[THE_FIELD_INDEX] > 0)
Posts: 30
Joined: 17-Sep-2006
# Posted on: 09-Oct-2007 14:12:14   

My mistake. You need to place it within the HAVING clause of the GROUP BY, rather than as a predicate expression on the relations.