本文整理汇总了C#中Where.Build方法的典型用法代码示例。如果您正苦于以下问题:C# Where.Build方法的具体用法?C# Where.Build怎么用?C# Where.Build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Where
的用法示例。
在下文中一共展示了Where.Build方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Or_Expression
public void Or_Expression()
{
var expr =
new Where<TestClass>().Like(x => x.A, "Alice").Or().SmallerThan(x => x.B, 2);
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE [AA] LIKE @A OR [B]<@B",
sql);
Assert.AreEqual(2, param.Count);
}
示例2: And_Expression_2
public void And_Expression_2()
{
var expr =
new Where<TestClass>().Group(g => g.Like(x => x.A, "Alice").And().SmallerThan(x => x.B, 2));
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE ([AA] LIKE @A AND [B]<@B)",
sql);
Assert.AreEqual(2, param.Count);
}
示例3: Complex_Expression_1
public void Complex_Expression_1()
{
var expr =
new Where<TestClass>().IsEqual(x => x.A, "Bob")
.And(g => g.Like(x => x.B, "Alice").Or().SmallerThan(x => x.C, 2))
.And(g => g.GreaterThanOrEqualTo(x => x.C, 3).Or().IsEqual(x => x.D, "Chris"));
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE [AA][email protected] AND ([B] LIKE @B OR [CC]<@C) AND ([CC]>[email protected] OR [D][email protected])",
sql);
Assert.AreEqual(5, param.Count);
}
示例4: Or_Used_As_Compound_Expression
public void Or_Used_As_Compound_Expression()
{
var expr =
new Where<TestClass>().IsEqual(x => x.A, "Bob")
.Or(g => g.Like(x => x.B, "Alice"));
var param = new Dictionary<string, object>();
var sql = expr.Build(param).ToString();
Assert.AreEqual(
"WHERE [AA][email protected] OR ([B] LIKE @B)",
sql);
Assert.AreEqual(2, param.Count);
}