public List <PRDYearMonthCrustReqDate> GetSearchInformation() { using (_context) { var Data = (from r in _context.PRD_YearMonthFinishReqDate.AsEnumerable() //where r.RecordStatus == "NCF" join s in _context.PRD_YearMonthSchedule on r.ScheduleID equals s.ScheduleID into Schedules from s in Schedules.DefaultIfEmpty() join y in _context.PRD_YearMonth on(s == null? null: s.YearMonID) equals y.YearMonID into YearMonths from y in YearMonths.DefaultIfEmpty() join st in _context.SYS_Store on(y == null?null:y.ProductionFloor) equals st.StoreID into Stores from st in Stores.DefaultIfEmpty() join c in _context.SYS_Store on(y == null? null: y.ConcernStore) equals c.StoreID into ConcernStores from c in ConcernStores.DefaultIfEmpty() orderby r.RequisitionDateID descending select new PRDYearMonthCrustReqDate { RequisitionDateID = r.RequisitionDateID, ScheduleID = r.ScheduleID, ScheduleNo = s == null? null: s.ScheduleNo, RequisitionNo = r.RequisitionNo, RequiredDate = Convert.ToDateTime(r.RequiredDate).ToString("dd'/'MM'/'yyyy"), RecordStatus = (r.RecordStatus == "NCF" ? "Not Confirmed" : "Confirmed"), PrepareDate = Convert.ToDateTime(s == null ? null : s.PrepareDate).ToString("dd'/'MM'/'yyyy"), YearMonID = (y == null? 0: y.YearMonID), ScheduleMonth = (y == null ? null : y.ScheduleMonth), ScheduleMonthName = (y == null ? null : DalCommon.ReturnMonthName(y.ScheduleMonth)), ScheduleYear = (y == null ? null : y.ScheduleYear), ProductionFloor = (y == null ? null : y.ProductionFloor), ProductionFloorName = (st == null ? null : st.StoreName), ConcernStore = (y == null ? null : y.ConcernStore), ConcernStoreName = (c == null ? null : c.StoreName), Remark = r.Remark }).ToList(); return(Data); } }