I've created a column in my table with the Geography type using entity framework code first. I'm calling a linq statement to fetch the first result from my table that compares the location I pass in with all locations in the table. What I want is to just return all rows that are within 20 miles or less of my location.
Here is what I have so far.
var myLocation = DbGeography.FromText("POINT(-122.453164 37.723057)");
using (var repo = new YogaSpaceRepository())
{
YogaSpace space = repo.FirstWithinDistance(myLocation);
}
public YogaSpace FirstWithinDistance(DbGeography myLocation)
{
var yogaSpace = (from u in context.YogaSpaces
orderby u.Location.Distance(myLocation)
select u).FirstOrDefault();
return yogaSpace;
}