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

Type() public static method

Tests that the type of the named element is equal to some type (see $type).
public static Type ( string name, BsonType type ) : QueryConditionList
name string The name of the element to test.
type BsonType The type to compare to.
return QueryConditionList
        public static QueryConditionList Type(string name, BsonType type)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            return new QueryConditionList(name).Type(type);
        }

Usage Example

        public void TestType()
        {
            var query    = Query.Type("a", BsonType.String);
            var expected = "{ \"a\" : { \"$type\" : 2 } }";

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