Hi,
I search a simple example to use CreateCriteria with tables JOIN.
Today, I use the following code in my program:
Code:
NHibernate.ISQLQuery qry =
session.CreateSQLQuery("SELECT Patients.last_name, Patients.patient_id, Patients.birth_date, Tests.acquisition_date, Tests.signature_date, Tests.signature, Tests.id_test, Tests.test_type FROM Tests INNER JOIN Patients ON Tests.id_patient = Patients.id_patient WHERE Tests.Enabled = 1");
ViewedTests result = new ViewedTests();
foreach (object[] item in qry.List())
{
result.Add(new ViewedTest()
{
LastName = (String)item[0],
Patient_id = (String)item[1],
Birth_date = (DateTime?)item[2],
Acquisition_Date = (DateTime?)item[3],
Signature_Date = (DateTime?)item[4],
Signature = (String)item[5],
Id = (Int32)item[6],
CodeTest = (Int32)item[7]
});
}
return result;
Is it possible to do the same thing with ICriteria, more easy to add several filters and order on my query.
Papy!