Click here to Skip to main content
15,905,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create Nhibernate criteria for the follwing query but not getting the right idea.
SELECT PEH.ResponseStatus FROM PatientEligibilityHistory PEH WHERE PEH.PatientId = " + patientId + " AND PEH.PayorId = " + payorId  + " AND PEH.DateOfService = '" + dateOfService + "' AND PEH.Insured_Id = '" + insuredId + "' HAVING PEH.ResponseDateTime = MAX(PEH.ResponseDateTime) 

I am trying the following Nhibernate Criteria but it is not working .

ICriteria criteria = session.CreateCriteria(typeof(PatientEligibilityHistory));
           criteria.Add(Expression.And(Expression.In("PatientId", patientList), Expression.In("PatientCaseId", patientCaseList)));
           criteria.Add(Expression.And(Expression.In("PayorId", payorList), Expression.In("InsuredId", insuredList)));
           ProjectionList projectionList = Projections.ProjectionList();
           projectionList.Add(Projections.Max("ResponseDatetime"));
           projectionList.Add(Projections.GroupProperty("ResponseDatetime"));
           criteria.SetProjection(projectionList);
           return criteria;

Please guide.
Posted

1 solution

SQL
SELECT PEH.ResponseStatus FROM PatientEligibilityHistory PEH WHERE PEH.PatientId = " + patientId + " AND PEH.PayorId = " + payorId  + " AND PEH.DateOfService = '" + dateOfService + "' AND PEH.Insured_Id = '" + insuredId + "' HAVING PEH.ResponseDateTime = select MAX(PEH.ResponseDateTime)  from  PatientEligibilityHistory
 
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