SortClause Error

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 31-Oct-2011 18:05:03   

Hi,

I am trying to add sorting for my adapter. It seems like sorter clause accepts sorttofield type ORMSupportClass.IEntityField and sort operator parameter. when I am passing fieldname, that field is of type ORMSupportClass.IEntityField2 it requires typecast, but if i do typecase it just throws exception "Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityField2' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'."

Please guide me how i can use sorter.

here is my code:

Dim sorter As New SD.LLBLGen.Pro.ORMSupportClasses.SortExpression() sorter.Add(New SD.LLBLGen.Pro.ORMSupportClasses.SortClause(HelperClasses.EmpFormFields.LastUpdatedTimestamp,SortOperator.Descending))

Thanks

Rishi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Nov-2011 05:17:33   

Hi Rishi,

You must use the adapter's overload that accepts an IPersistenceInfo parameter, you just pass Nothing to it:

Dim sorter As New SortExpression()
sorter.Add(New SortClause(EmpFormFields.LastUpdatedTimestamp, Nothing, SortOperator.Descending))

You also can use this version:

Dim sorter As New SortExpression()
sorter.Add(New SortClause(EmpFormFields.LastUpdatedTimestamp Or SortOperator.Descending))

This is described in detail in the Adapter - Sorting manual's section.

Hope helpful wink

David Elizondo | LLBLGen Support Team