2

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?

Chris Catignani
  • 5,040
  • 16
  • 42
  • 49
  • can you please tell us if the executed the code in your question and if yes what is the error you are getting or what is not working exactly – Tamir Klein May 07 '19 at 14:18
  • No, I just do not know how to write geographic queries in the C# code :( – champion... May 07 '19 at 14:22
  • Since SO is not a coding service the best way it to give it a go show the effort you have done which will encourage others to help you once you get stuck – Tamir Klein May 07 '19 at 14:24
  • 1
    https://stackoverflow.com/questions/33986155/how-do-i-use-a-geospatial-query-in-the-2-1-mongodb-c-sharp-driver – Mihir Dave May 07 '19 at 14:47

1 Answers1

1

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