Avatar of Waterside
Waterside
 asked on

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

.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Waterside

8/22/2022 - Mon
Fernando Soto

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
Waterside

ASKER
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 Soto

What do you want the results to look like?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Waterside

ASKER
Ah sorry, I missed of the start..

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

Open in new window

ASKER CERTIFIED SOLUTION
Fernando Soto

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Waterside

ASKER
Well spotted.  I forgot to change Dictionary to ListOf.. All is good now thanks'
Waterside

ASKER
thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.