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

Matches() public static method

Tests that the value of the named element matches a regular expression (see $regex).
public static Matches ( string name, BsonRegularExpression regex ) : QueryComplete
name string The name of the element to test.
regex BsonRegularExpression The regular expression to match against.
return QueryComplete
        public static QueryComplete Matches(string name, BsonRegularExpression regex)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (regex == null)
            {
                throw new ArgumentNullException("regex");
            }
            return new QueryComplete(new BsonDocument(name, regex));
        }

Usage Example

        public void TestMatches()
        {
            var query    = Query.Matches("a", "/abc/");
            var expected = "{ 'a' : /abc/ }".Replace("'", "\"");

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