Sort by aggregate column in typedlist

Posts   
 
    
Posts: 2
Joined: 06-Feb-2015
# Posted on: 06-Feb-2015 15:18:21   

Hello!

I have defined a typed list which contains an aggregate field, count distinct. Now, I'm trying to retrieve that typed list with the data sorted by that aggregate field. I have been trying to create a SortClause, but that requires an entity field, whereas my field is only defined for the typed list.

Thank you!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Feb-2015 07:24:18   

Please show us your code and the approximate results you want to achieve.

David Elizondo | LLBLGen Support Team
Posts: 2
Joined: 06-Feb-2015
# Posted on: 08-Feb-2015 09:26:19   

Hello!

I have a table, for example, Person: Id FirstName LastName CountryId

And I create a typed list in LLBLGen, PersonTypedList: NumberOfPeople - as an aggregate field: Count(Id) CountryId

And in my code I'll have something like this:

PersonTypedList typedList = new PersonTypedList();

IRelationPredicateBucket bucket = typedList.GetRelationsInfo();

GroupByCollection groupBy = new GroupByCollection();
groupBy.Add(PersonFields.CountryId);

ISortExpression sorter = new SortExpression();
//and this is where i want to add a sort clause to order by the NumberOfPeople field.

Is this achievable in this way? Or is there another method? Thank you!

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 09-Feb-2015 06:39:37   

You should use Sorting on Expressions. This documentation link is for EntityCollections, but it should work with your TypedList as well.

David Elizondo | LLBLGen Support Team