public static IQueryable <TableJoinResult> GetLaboratoryExamination(ExaminationsSearchCriteria searchCriteria) { DataClassesDataContext db = new DataClassesDataContext(); IQueryable <TableJoinResult> query = (from app in db.Appointment join st in db.Staff on app.Id_Doctor equals st.Id_Staff join lab in db.Examination_Laboratory on app.Id_Appointment equals lab.Id_Appointment join dic in db.Exam_Dictionary on lab.Exam_Code equals dic.Exam_Code select new TableJoinResult { appointmentTable = app, laboratoryExaminationTable = lab, staffTable = st, examDictionaryTable = dic }); if (searchCriteria.getPatientId() != 0) { query = query.Where(app => app.appointmentTable.Id_Patient.Equals(searchCriteria.getPatientId())); } if (searchCriteria.getAppointmentId() != 0) { query = query.Where(app => app.appointmentTable.Id_Appointment.Equals(searchCriteria.getAppointmentId())); } if (searchCriteria.getExaminationId() != 0) { query = query.Where(lab => lab.laboratoryExaminationTable.Id_Examination.Equals(searchCriteria.getExaminationId())); } return(query); }
public static IQueryable <TableJoinResult> GetPhysicalExamination(ExaminationsSearchCriteria searchCriteria) { DataClassesDataContext db = new DataClassesDataContext(); IQueryable <TableJoinResult> query = (from app in db.Appointment join st in db.Staff on app.Id_Doctor equals st.Id_Staff join phy in db.Examination_Physical on app.Id_Appointment equals phy.Id_Appointment join dic in db.Exam_Dictionary on phy.Exam_Code equals dic.Exam_Code select new TableJoinResult { appointmentTable = app, physicalExaminationTable = phy, staffTable = st, examDictionaryTable = dic }); if (searchCriteria.getPatientId() != 0) { query = query.Where(app => app.appointmentTable.Id_Patient.Equals(searchCriteria.getPatientId())); } if (searchCriteria.getAppointmentId() != 0) { query = query.Where(app => app.appointmentTable.Id_Appointment.Equals(searchCriteria.getAppointmentId())); } if (searchCriteria.getExaminationId() != 0) { query = query.Where(phy => phy.physicalExaminationTable.Id_Examination.Equals(searchCriteria.getExaminationId())); } if (searchCriteria.getExaminationName() != "") { query = query.Where(dic => dic.examDictionaryTable.Name.Equals(searchCriteria.getExaminationName())); } return(query); }