示例#1
0
        public IQueryable <TLCUT_CutSheet> SelectWIPCutSheets(CuttingQueryParameters parameters)
        {
            IQueryable <TLCUT_CutSheet> CS;

            if (parameters.AllWIP)
            {
                CS = _context.TLCUT_CutSheet.Where(x => !x.TLCutSH_WIPComplete && x.TLCutSH_Accepted && !x.TLCutSH_Closed).AsQueryable();
            }
            else
            {
                CS = _context.TLCUT_CutSheet.Where(x => x.TLCutSH_Date >= parameters.FromDate && x.TLCutSH_Date <= parameters.ToDate && !x.TLCutSH_WIPComplete && x.TLCutSH_Accepted && !x.TLCutSH_Closed).AsQueryable();
            }

            if (parameters.Departments.Count != 0)
            {
                var DeptPredicate = PredicateBuilder.False <TLCUT_CutSheet>();
                foreach (var Dept in parameters.Departments)
                {
                    var temp = Dept;
                    DeptPredicate = DeptPredicate.Or(s => s.TLCutSH_Department_FK == Dept.Dep_Id);
                }

                CS = CS.AsExpandable().Where(DeptPredicate);
            }

            if (parameters.Qualities.Count != 0)
            {
                var CSPredicate = PredicateBuilder.False <TLCUT_CutSheet>();
                foreach (var CSR in parameters.Qualities)
                {
                    var temp = CSR;
                    CSPredicate = CSPredicate.Or(s => s.TLCutSH_Quality_FK == temp.TLGreige_Id);
                }

                CS = CS.AsExpandable().Where(CSPredicate);
            }

            if (parameters.Colours.Count != 0)
            {
                var CSColourPredicate = PredicateBuilder.False <TLCUT_CutSheet>();
                foreach (var Colour in parameters.Colours)
                {
                    var temp = Colour;
                    CSColourPredicate = CSColourPredicate.Or(s => s.TLCutSH_Colour_FK == temp.Col_Id);
                }

                CS = CS.AsExpandable().Where(CSColourPredicate);
            }
            return(CS);
        }