MongoDB.Driver.Builders.DeprecatedQuery.Near C# (CSharp) Method

Near() public static method

Tests that the value of the named element is near some location (see $near).
public static Near ( string name, double x, double y ) : QueryConditionList
name string The name of the element to test.
x double The x value of the origin.
y double The y value of the origin.
return QueryConditionList
        public static QueryConditionList Near(string name, double x, double y)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            return new QueryConditionList(name).Near(x, y);
        }

Same methods

DeprecatedQuery::Near ( string name, double x, double y, double maxDistance ) : QueryConditionList
DeprecatedQuery::Near ( string name, double x, double y, double maxDistance, bool spherical ) : QueryConditionList

Usage Example

        public void TestNearWithSphericalTrue()
        {
            var query    = Query.Near("loc", 1.1, 2.2, 3.3, true);
            var expected = "{ 'loc' : { '$nearSphere' : [1.1, 2.2], '$maxDistance' : 3.3 } }".Replace("'", "\"");

            Assert.AreEqual(expected, query.ToJson());
        }
All Usage Examples Of MongoDB.Driver.Builders.DeprecatedQuery::Near