public static ElemMatch ( string name, IMongoQuery query ) : |
||
name | string | The name of the element to test. |
query | IMongoQuery | The query to match elements with. |
Результат |
public static QueryConditionList ElemMatch(string name, IMongoQuery query)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (query == null)
{
throw new ArgumentNullException("query");
}
return new QueryConditionList(name).ElemMatch(query);
}
public void TestElementMatch() { var query = Query.ElemMatch("x", Query.And( Query.EQ("a", 1), Query.GT("b", 1) ) ); var expected = "{ \"x\" : { \"$elemMatch\" : { \"a\" : 1, \"b\" : { \"$gt\" : 1 } } } }"; Assert.AreEqual(expected, query.ToJson()); }