本文整理汇总了C#中Query.Or方法的典型用法代码示例。如果您正苦于以下问题:C# Query.Or方法的具体用法?C# Query.Or怎么用?C# Query.Or使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query.Or方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestOr
public void TestOr()
{
var q = new Query("Release.Name", Query.Operator.Equals, "My Release");
Assert.AreEqual(q.QueryClause, "(Release.Name = \"My Release\")");
Query q2 = q.Or(new Query("Iteration.Name", Query.Operator.Equals, "My Iteration"));
Assert.AreEqual(q2.QueryClause, "((Release.Name = \"My Release\") OR (Iteration.Name = \"My Iteration\"))");
}
示例2: TestOr
public void TestOr()
{
Query query = new Query().Field("region").In("MA", "VT", "NH");
query.Or(
query.Field("first_name").Equal("Chun"),
query.Field("last_name").Equal("Kok")
);
//Assert
AreEqualQueries("filters={\"$and\":[{\"region\":{\"$in\":[\"MA\",\"VT\",\"NH\"]}},{\"$or\":[{\"first_name\":{\"$eq\":\"Chun\"}},{\"last_name\":{\"$eq\":\"Kok\"}}]}]}", query);
}
示例3: TestNestedFilters
public void TestNestedFilters()
{
//Arrange
Query query = new Query();
query.Or(
query.And(
query.Field("city").Equal("Los Angeles"),
query.Field("score").Equal("38")
),
query.Or(
query.Field("last_name").Equal("Kok"),
query.Field("first_name").Equal("Chun")
)
);
//Assert
AreEqualQueries("filters={\"$or\":[{\"$and\":[{\"city\":{\"$eq\":\"Los Angeles\"}},{\"score\":{\"$eq\":\"38\"}}]},{\"$or\":[{\"last_name\":{\"$eq\":\"Kok\"}},{\"first_name\":{\"$eq\":\"Chun\"}}]}]}",query);
}
示例4: TestNestedOrWithinTheTopLevelAnd
public void TestNestedOrWithinTheTopLevelAnd()
{
//Arrange & Act
var query = new Query().Field("region").In("MA", "VT", "NH");
query.Or
(
query.Field("name").BeginsWith("Coffee"),
query.Field("name").BeginsWith("Star")
);
var response = Factual.Fetch("places", query);
AssertReceivedOkResponse(response);
AssertNotEmpty(response);
AssertStartsWithEither(response, "name", "Coffee", "Star");
var raw = Factual.RawQuery("t/places", "filters={\"$and\":[{\"region\":{\"$in\":[\"MA\",\"VT\",\"NH\"]}},{\"$or\":[{\"name\":{\"$bw\":\"Coffee\"}},{\"name\":{\"$bw\":\"Star\"}}]}]}");
//Assert
Assert.AreEqual(response, raw);
}