Hello i'm trying to convert this query into nhibernate... .
Can some help me out?
the qry directly on the db (oracle database):
Code:
SELECT DISTINCT * FROM APPLICATION.PATIENT P join admission a on p.patientkey = a.patientkey
WHERE not exists (select * from document d where d.patientkey = p.patientkey and d.rubriccode = '0100101003') and a.patientclass = 'I' and a.admissiondate BETWEEN to_date('20090101','yyyymmdd') and to_date('20100401','yyyymmdd') order by p.patientkey;
This is my try on the ActiveRecordLinqBase
Code:
IEnumerable<Patient> pat = (from patient in ActiveRecordLinq.AsQueryable<Patient>()
from adm in patient.Admissions
where !(from doc in ActiveRecordLinq.AsQueryable<Document>() where doc.RubricCode.Equals("0100101003") select doc.PatientKey).Contains(patient.PatientKey) && adm.PatientClass.Equals("I") && adm.AdmissionDate >= new DateTime(2009, 01, 01) && adm.AdmissionDate <= new DateTime(2010, 01, 01)
select patient).Distinct();
The query without the ! contains operator works fine... . The error is :
error:
Code supposed to be unreachable
STack:
Code:
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteExpression(Expression node, Stack stack)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.Add(Expression node)
at System.Linq.Expressions.Compiler.StackSpiller.ChildRewriter.AddArguments(IArgumentProvider expressions)
at System.Linq.Expressions.Compiler.StackSpiller.RewriteMethodCallExpression(Expression expr, Stack stack)
Thx for the help!