Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use a geospatial query in the MongoDB C#?

How can I run geo queries using C#

Something as simple as this:

db.restaurants.find({ location:
       { $geoWithin:
          { $centerSphere: [ [ -73.93414657, 40.82302903 ], 5 / 3963.2 ] } } })

Any ideas on how I can do this?

like image 786
champion... Avatar asked Dec 07 '25 04:12

champion...


1 Answers

I got along, Here's how:

var filter = Builders<BsonDocument>.Filter.GeoWithinCenterSphere("location", -73.93414657, 40.82302903 ,5 / 3963.2);

var results =  collection.Find(filter).toList();

Thanks

like image 161
champion... Avatar answered Dec 08 '25 16:12

champion...