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

Waterside
Waterside used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fernando SotoRetired
Distinguished Expert 2017

Commented:
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

Author

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 SotoRetired
Distinguished Expert 2017

Commented:
What do you want the results to look like?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Author

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

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

Open in new window

Retired
Distinguished Expert 2017
Commented:
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?

Author

Commented:
Well spotted.  I forgot to change Dictionary to ListOf.. All is good now thanks'

Author

Commented:
thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial