VB.Net 2005 ISortClause w/two fields

Posts   
 
    
TogasPoon
User
Posts: 42
Joined: 09-Feb-2006
# Posted on: 16-May-2006 23:53:41   

Using self serving, two class, vb 2005

I'm in the process of changing my code to the VB.net 2005 syntax and I'm running into problems when I try and sort on more than 1 field.

This is what I have

Dim sorter As New SortExpression(EmployeeFields.LastName Or SortOperator.Ascending) And _ 
    (EmployeeFields.FirstName Or SortOperator.Descending)

Which gives me this error: end of expression expected.

Both LastName and FirstName on their own work.

I've tried

Dim sorter As New SortExpression((EmployeeFields.LastName Or SortOperator.Ascending) And _ 
    (EmployeeFields.FirstName Or SortOperator.Descending))

This compiles but gives me this error when I open the page.

Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.SortExpression' to type 'SD.LLBLGen.Pro.ORMSupportClasses.ISortClause'.
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 17-May-2006 09:49:19   

The 'And' operator between sortclauses doesn't seem to work. I'll remove it. The operator overloads were introduced at a late point during development/beta of 1.0.2005.1 and once released turned out to be a great help in one area but in another area there were some small glitches here and there.

The error you run into is caused by the fact that AND needs to return the same type as the operands, which isn't the case as the two operands are SortClauses and the operator returns a sortexpression.

So do: Dim sorter As New SortExpression(EmployeeFields.LastName Or SortOperator.Ascending) sorter.Add(EmployeeFields.FirstName Or SortOperator.Descending)

instead.

Frans Bouma | Lead developer LLBLGen Pro
TogasPoon
User
Posts: 42
Joined: 09-Feb-2006
# Posted on: 17-May-2006 15:23:56   

Works great.

Thanks simple_smile