示例#1
0
        public IQueryable <JobOrderInspectionHeaderViewModel> GetJobOrderInspectionHeaderList(int DocTypeId, string Uname)
        {
            var DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];
            var SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];

            return(from p in db.JobOrderInspectionHeader
                   join J in db.Persons on p.JobWorkerId equals J.PersonID into JTable
                   from JTab in JTable.DefaultIfEmpty()
                   join E in db.Persons on p.InspectionById equals E.PersonID into ETable
                   from ETab in ETable.DefaultIfEmpty()
                   orderby p.DocDate descending, p.DocNo descending
                   where p.SiteId == SiteId && p.DivisionId == DivisionId && p.DocTypeId == DocTypeId
                   select new JobOrderInspectionHeaderViewModel
            {
                JobOrderInspectionHeaderId = p.JobOrderInspectionHeaderId,
                DocDate = p.DocDate,
                DocNo = p.DocNo,
                JobWorkerName = JTab.Name,
                InspectionByName = ETab.Name,
                DocTypeName = p.DocType.DocumentTypeName,
                Remark = p.Remark,
                Status = p.Status,
                ModifiedBy = p.ModifiedBy,
                ReviewCount = p.ReviewCount,
                ReviewBy = p.ReviewBy,
                Reviewed = (SqlFunctions.CharIndex(Uname, p.ReviewBy) > 0),
            }
                   );
        }