Keld Jakobsen
Keld Jakobsen

Reputation: 193

Nhibernate ICRITERIA syntax

I have the following sql :

       Select * from table where (Field1=1 and Field2=1) or (Field3=1)

How do i create the selection using NHibernate ICriteria Regards Keld

Upvotes: 1

Views: 1476

Answers (1)

harriyott
harriyott

Reputation: 10645

Use Restrictions.Or and Restrictions.And

Session
.CreateCriteria<Table>()
.Add(Restrictions.Or(
    Restrictions.And(
        Restrictions.Eq("Field1", 1),
        Restrictions.Eq("Field2", 1)),
    Restrictions.Eq("Field3", 1))
.List<Table>();

Upvotes: 3

Related Questions