首页 > 解决方案 > 如何在 MongoDB C# 中使用地理空间查询?

问题描述

如何使用 C# 运行地理查询

像这样简单的事情:

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

关于如何做到这一点的任何想法?

标签: c#.netmongodb-querygeospatial

解决方案


我相处融洽,方法如下:

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

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

谢谢


推荐阅读