我对 MongoDB 了解不多,但似乎 mongodb-csharp 代码尚未更新为使用$geoWithin
,如您在此处看到的:
mongo-csharp-driver (QueryBuilder)
public static IMongoQuery WithinCircle(string name, double centerX, double centerY, double radius, bool spherical)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
var shape = spherical ? "$centerSphere" : "$center";
var condition = new BsonDocument("$within", new BsonDocument(shape, new BsonArray { new BsonArray { centerX, centerY }, radius }));
return new QueryDocument(name, condition);
}
看,它使用$within
.
由于该库是开源的,因此您可以分叉、编辑和重新编译它,并使用您自己的版本。此外,您可以提出拉取请求以提议您的更改包含在主代码中。
我认为没有“更简单”的方法可以做到这一点,我希望这会有所帮助。