Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I want to create criteria for a query but it is not working ? The query is
SELECT * FROM patientdetailinformationview where (patientid=101 and PatientCaseId=1316) or (patientid=105 and Case_type=1)

Please guide in this regard. Thanks in advance

1 solution

You need to have two separate conjunctions added to a single disjunction. Something like:

var conjunction1 = Restrictions.Conjunction();
conjunction1.Add(Restrictions.Eq("patientid", 101));
conjunction1.Add(Restrictions.Eq("PatientCaseId", 1316));

var conjunction2 = Restrictions.Conjunction();
conjunction2.Add(Restrictions.Eq("patientid", 105));
conjunction2.Add(Restrictions.Eq("Case_type", 1));

var orDisjunction = Restrictions.Disjunction();


return session.CreateCriteria(typeof(PatientDetailInformation))

Hope it helps.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900