如何使用DetachedCriteria实现此查询:
Select * from
MyTable
Where
(conditionA = true) or
(conditionB = true) or
(conditionC = true) or
(conditionD = true)
答案 0 :(得分:5)
像这样:
DetachedCriteria.For<MyTable>()
.Add(Restrictions.Eq("conditionA", true) ||
Restrictions.Eq("conditionB", true) ||
Restrictions.Eq("conditionC", true) ||
Restrictions.Eq("conditionD", true));
答案 1 :(得分:3)
您可以像这样使用Disjunction类:
DetachedCriteria.For<MyTable>()
.Add(Restrictions.Disjunction()
.Add(Restrictions.Eq("conditionA", true))
.Add(Restrictions.Eq("conditionB", true))
.Add(Restrictions.Eq("conditionC", true))
.Add(Restrictions.Eq("conditionD", true)));