Reputation: 123
Forgive my ignorance on this. I have this LINQ Query: Dim ngBikersDataContext As New CarBikeWalkDataContext
bikersList = (From c In ngBikersDataContext.Reg_Bikers _
Order By c.L_Name _
Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()
As you can see it is a LIST(OF ). Here is the definition of the bikersList:
Dim bikersList As List(Of Bikers) = TryCast(HttpContext.Current.Session("Bikers"), List(Of Bikers))
I need to be able to sort, so was going to use the Dynamic LINQ Library. So I added it to my project Imported System.Linq.Dynamic and tried to use this code:
bikersList = (ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()
But now I am getting the blue scwiggly line under:
ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select
with the error "Overload resolution failed because no accesible 'Select' accepts this number of arguments." Over the "NEW" I get an error " ')'expected."
Would someone please tell me what I am doing wrong. Thank You
Upvotes: 2
Views: 271
Reputation: 26782
You're mixing up 'extension method' syntax with 'query syntax'.
bikersList = (ngBikersDataContext.Reg_Bikers _
.OrderBy(SortExpression) _
.Select(Function(c) New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
})).ToList()
Or
bikersList = (From c in ngBikersDataContext.Reg_Bikers.OrderBy(SortExpression) _
Select b = New Bikers() With { _
.BikerID = c.BikerID, _
.F_Name = c.F_Name, _
.M_Name = c.M_Name, _
.L_Name = c.L_Name _
}).ToList()
Upvotes: 1