Sorting on TypedLists

Posts   
 
    
heuertk
User
Posts: 5
Joined: 20-Jan-2005
# Posted on: 15-Feb-2005 02:56:11   

If you create a typed list in the tool which generates a custom TypedList class...

how can you then put sort expressons on that?

I tried the usual SortExpression and adding that to the FetchTypedList function, but the exception was thrown that my table names did not match aliases in the database?

however after just changing my code to use defined resultset fields, it works fine...

i'd rather use the typedlist in advance to keep other developers consistent.

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 15-Feb-2005 04:15:58   

It should work, you must be doing something wrong. Here's an example using a filter and a sort.


            FilteredPODetailTypedList list = new FilteredPODetailTypedList();
            DataAccessAdapter adapter = new DataAccessAdapter();
            IRelationPredicateBucket bucket = (IRelationPredicateBucket)list.GetRelationInfo();
            bucket.PredicateExpression.Add(PredicateFactory.CompareValue(PODetailFieldIndex.PONumber, ComparisonOperator.Equal, PONumber));
            ISortExpression sort = new SortExpression(SortClauseFactory.Create(PODetailFieldIndex.POLineNumber, SortOperator.Ascending));
            adapter.FetchTypedList(list.GetFieldsInfo(), list, bucket, 0, sort, false);

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 15-Feb-2005 09:35:17   

Thanks for the answer, Jim!

Most common error is that developers forget to use the normal entity field indexes for the fields which are in the typed list. After all, a typed list is just build with entity fields.

Frans Bouma | Lead developer LLBLGen Pro
heuertk
User
Posts: 5
Joined: 20-Jan-2005
# Posted on: 16-Feb-2005 18:26:21   

i'm doing exactly that...using the entity fields for the sorter as well...but somehow whatever it is sending to the database is getting screwed up.

i'll reproduce and post my code and the resulting exception