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

WithinRectangle() public static method

Tests that the value of the named element is within a rectangle (see $within and $box).
public static WithinRectangle ( string name, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY ) : QueryConditionList
name string The name of the element to test.
lowerLeftX double The x coordinate of the lower left corner.
lowerLeftY double The y coordinate of the lower left corner.
upperRightX double The x coordinate of the upper right corner.
upperRightY double The y coordinate of the upper right corner.
return QueryConditionList
        public static QueryConditionList WithinRectangle(
            string name,
            double lowerLeftX,
            double lowerLeftY,
            double upperRightX,
            double upperRightY)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            return new QueryConditionList(name).WithinRectangle(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
        }

Usage Example

        public void TestWithinRectangle()
        {
            var query    = Query.WithinRectangle("loc", 1.1, 2.2, 3.3, 4.4);
            var expected = "{ 'loc' : { '$within' : { '$box' : [[1.1, 2.2], [3.3, 4.4]] } } }".Replace("'", "\"");

            Assert.AreEqual(expected, query.ToJson());
        }