Updating to 2.6

Posts   
 
    
BClausen
User
Posts: 4
Joined: 03-Apr-2009
# Posted on: 03-Apr-2009 01:02:39   

I am updating our code to the new version. I can not find how to declare the sort column in the function header so the sort expression can use it. In the older version we are passing the sort column as an object field index. The new version wants the sort expression as an IEntity. This is the code for our old version which is working fine:

Public Shared Function GetSearchResult_Old(ByVal AlgorithmName As String, ByVal AssessmentID As String, ByVal pageNumber As Integer, ByVal pageSize As Integer, Optional ByVal SortColumn As ScoringAlgorithmDetailsFieldIndex = ScoringAlgorithmDetailsFieldIndex.ScoringAlgorithmId, Optional ByVal SortDirection As SortOperator = SortOperator.Ascending) As CollectionClasses.ScoringAlgorithmDetailsCollection Dim arrAlgo As New CollectionClasses.ScoringAlgorithmDetailsCollection Dim searchFilter As PredicateExpression = GetSearchFilter(AlgorithmName, AssessmentID) Dim S As New SortExpression()

        **S.Add(FactoryClasses.SortClauseFactory.Create(SortColumn, SortDirection))**
        arrAlgo.GetMulti(searchFilter, pageSize, S, Nothing, pageNumber, pageSize)
        Dim arr As New UniqueValueList
        arr.Add(arrAlgo)

        Return arrAlgo
    End Function

We are passing the sort column as an argument. Which we use in the sort expression. We want to do the same thing in the new version. The function header uses field index in the older version and allows us to use that in the sort expression. The new version allows us to use the the field index in the function header but does wants an IEntity in the sort expression. The header if declared as an IEntity wants a constant as the default option and using the objectfields.fieldname does not work. What do I need to do for this to work. I haven't been able to find any examples of a complete function to see how arguments are passed and used. The examples I have seen used static strings and I haven't found any examples of arguments passed to the code.

The Converted function which does not work, the sort expression wants an IEntity not a objectfieldindex:

Public Shared Function GetSearchResult_Old(ByVal AlgorithmName As String, ByVal AssessmentID As String, ByVal pageNumber As Integer, ByVal pageSize As Integer, Optional ByVal SortColumn As ScoringAlgorithmDetailsFieldIndex = ScoringAlgorithmDetailsFieldIndex.ScoringAlgorithmId, Optional ByVal SortDirection As SortOperator = SortOperator.Ascending) As CollectionClasses.ScoringAlgorithmDetailsCollection Dim arrAlgo As New CollectionClasses.ScoringAlgorithmDetailsCollection Dim F As PredicateExpression = GetSearchFilter(AlgorithmName, AssessmentID) Dim S As New SortExpression() S.Add(New SortClause(SortColumn, SortDirection) arrAlgo.GetMulti(F, pageSize, S, Nothing, pageNumber, pageSize)

        Return arrAlgo
    End Function

I hope I heve explained this well enough.

Thanks BClausen

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 03-Apr-2009 04:24:04   

Hi BClausen,

Use this code:

EntityField fieldToSort = (EntityField) new ScoringAlgorithmDetailsEntityFactory().CreateFields()[(int)SortColumn];
SortExpression S = new SortExpression(fieldToSort | SortOperator.Ascending);

HTH wink

David Elizondo | LLBLGen Support Team
BClausen
User
Posts: 4
Joined: 03-Apr-2009
# Posted on: 03-Apr-2009 17:53:29   

Thanks for the help