Friday, 24 October 2014

Search within range with LINQ and DbGeography

    var myLocation = DbGeography.FromText(string.Format("POINT({0} {1})", lon, lat)); 
    var result = (from u in _db.Restaurants
           orderby u.Location.Distance(myLocation)
           where u.Location.Distance(myLocation) < distance
           select u).Take(limit).ToList();
distance is a double and its value is in meters.

No comments:

Post a Comment