2

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

1 Answer 1

1

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()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.