コード例 #1
0
        internal static IEnumerable <Expression <Func <Lot, LotSummaryReturn> > > SplitSelectLotSummary(ILotUnitOfWork lotUnitOfWork, DateTime currentDate)
        {
            if (lotUnitOfWork == null)
            {
                throw new ArgumentNullException("lotUnitOfWork");
            }

            var attributes = LotAttributeProjectors.Select();
            var lotDefects = LotDefectProjectors.SelectLotDefect();
            var product    = SelectDerivedProduct();
            var loBac      = SelectLoBac();
            var astaCalc   = SelectAstaCalc(lotUnitOfWork, currentDate);

            var customer          = PackScheduleProjectors.SelectCustomerHeader();
            var productionBatches = lotUnitOfWork.ProductionBatchRepository.All();
            var lotKeyFilter      = LotPredicates.ConstructLotKeyPredicate <Lot, ProductionBatch>();

            return(new[]
            {
                SelectLotBase().Merge(l => new LotSummaryReturn
                {
                    LotDateCreated = l.LotDateCreated,
                }).ExpandAll(),

                Projector <Lot> .To(l => new LotSummaryReturn
                {
                    AstaCalcDate = currentDate,
                    Attributes = l.Attributes.Select(a => attributes.Invoke(a)),
                    Defects = l.LotDefects.OrderBy(d => d.DefectId).Select(d => lotDefects.Invoke(d))
                }),

                Projector <Lot> .To(l => new LotSummaryReturn
                {
                    LoBac = loBac.Invoke(l),
                    LotProduct = product.Invoke(l),
                }),

                Projector <Lot> .To(l => new LotSummaryReturn
                {
                    AstaCalc = astaCalc.Invoke(l),
                }),

                Projector <Lot> .To(l => new LotSummaryReturn
                {
                    Customer = productionBatches
                               .Where(lotKeyFilter.Invoke(l))
                               .Select(b => customer.Invoke(b.PackSchedule)).FirstOrDefault()
                })
            });
        }