LinqToSQL Range variable name can be inferred only from a simple or qualified name with no arguments

I am trying combine two columns (latitude and longitude) into a new coordinate using linqToSQL, but I get the error..

Range variable name can be inferred only from a simple or qualified name with no arguments

Here is my code..

Using dc = New Context(ConnectionString)
                Dim data = From d In dc.Routes Where routeId = routeId Select d.PlaceName, New GeoCoordinate(d.Latitude, d.Longitude)
                Return data.ToList
End Using

Open in new window

WatersideAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi;

Try it like this.

Using dc = New Context(ConnectionString)
                Dim data = From d In dc.Routes Where routeId = routeId Select d.PlaceName, LatLong = New GeoCoordinate(d.Latitude, d.Longitude)
                Return data.ToList
End Using
WatersideAuthor Commented:
That fixes the query def but breaks data.ToList as it is returning an anonymouse type.

I had hoped that LatLong As GeoCoordinate might have helped, but no :(
Fernando SotoRetiredCommented:
What do you want the results to look like?
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

WatersideAuthor Commented:
Ah sorry, I missed of the start..

Private Function getDbLocations(roundId As Integer) As Dictionary(Of String, GeoCoordinate)

Open in new window

Fernando SotoRetiredCommented:
Let me ask the question this way. After calling the query what do you what the variable data to contain? In the original query you had two values being returned in a List(Of , .. ) object but in your last post you are saying it is a Dictionary(Of String, GeoCoordinate). What does a GeoCoordinate object contain?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
WatersideAuthor Commented:
Well spotted.  I forgot to change Dictionary to ListOf.. All is good now thanks'
WatersideAuthor Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.