How can I achieve this query using DetachedCriteria:
Select * from
MyTable
Where
(conditionA = true) or
(conditionB = true) or
(conditionC = true) or
(conditionD = true)
How can I achieve this query using DetachedCriteria:
Select * from
MyTable
Where
(conditionA = true) or
(conditionB = true) or
(conditionC = true) or
(conditionD = true)
Like this:
DetachedCriteria.For<MyTable>()
.Add(Restrictions.Eq("conditionA", true) ||
Restrictions.Eq("conditionB", true) ||
Restrictions.Eq("conditionC", true) ||
Restrictions.Eq("conditionD", true));
You can use the Disjunction class like so:
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)));