0

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();
chuckd
  • 13,460
  • 29
  • 152
  • 331

1 Answers1

0

Just remove the line

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

StefanFFM
  • 1,526
  • 1
  • 14
  • 25