LT() public static method

Tests that the value of the named element is less than some value (see $lt).
public static LT ( string name, BsonValue value ) : QueryConditionList
name string The name of the element to test.
value BsonValue The value to compare to.
return QueryConditionList
        public void TestLessThan()
        {
            var query    = Query.LT("k", 10);
            var expected = "{ \"k\" : { \"$lt\" : 10 } }";

            Assert.AreEqual(expected, query.ToJson());
        }
Beispiel #2
0
        public void TestEq1()
        {
            // now that server supports $and this is actually syntactically valid
            var query = Query.And(
                Query.EQ("value", 6),
                Query.LT("value", 20)
                );
            var expected = "{ '$and' : [{ 'value' : 6 }, { 'value' : { '$lt' : 20 } }] }".Replace("'", "\"");
            var json     = query.ToJson();

            Assert.AreEqual(expected, json);
        }
Beispiel #3
0
        public void TestAndGtLt()
        {
            var query = Query.And(
                Query.NotIn("value", 1, 2, 3),
                Query.EQ("OtherValue", 1),
                Query.GT("value", 6),
                Query.LT("value", 20)
                );

            Assert.AreEqual(
                new BsonDocument
            {
                { "value", new BsonDocument
                  {
                      { "$nin", new BsonArray {
                                1, 2, 3
                            } },
                      { "$gt", 6 },
                      { "$lt", 20 }
                  } },
                { "OtherValue", 1 }
            },
                query.ToBsonDocument());
        }