Removing a radius clause in my dbGeography linq-to-entity statement

38 Views Asked by At

How can I remove the 'radius' in my linq-to-entity statement so that it doesn't limit the search to the radius?

FYI - I want my query to search for names that start with the 'term' and search outward starting with the names that are closest to the location points, but not limiting it to a radius

DbGeography location = DbGeography.FromText("POINT(" + longitude.ToString() + " " + latitude.ToString() + ")");
            int radius = (50 * 5280); // 50 miles

            var namesList = (from N in dbContext.Profiles
                             where N.FullName.StartsWith(term) 
                             && N.LocationPoints.Distance(location) <= radius
                             orderby N.LocationPoints.Distance(location) ascending
                             select new ProfileNameSearch {
                                 label = N.FullName + " - " + N.Location,
                                 value = N.FullName,
                                 location = N.LocationPoints.Latitude.ToString() + "," + N.LocationPoints.Longitude.ToString()
                             }).Take(10).ToList();
1

There are 1 best solutions below

2
StefanFFM On

Just remove the line

&& N.LocationPoints.Distance(location) <= radius