internal static IEnumerable <Expression <Func <Lot, LotQualitySummaryReturn> > > SplitSelectLotQualitySummary(ILotUnitOfWork lotUnitOfWork, DateTime currentDate) { if (lotUnitOfWork == null) { throw new ArgumentNullException("lotUnitOfWork"); } var customerAllowance = LotCustomerAllowanceProjectors.Select(); var customerOrderAllowance = LotCustomerOrderAllowanceProjectors.Select(); var contractAllowance = LotContractAllowanceProjectors.Select(); return(SplitSelectLotSummary(lotUnitOfWork, currentDate) .Select(e => e.Merge(l => new LotQualitySummaryReturn { }).ExpandAll()) .ToListWithModifiedElement(0, e => e.Merge(l => new LotQualitySummaryReturn { ProductSpecComplete = l.ProductSpecComplete, ProductSpecOutOfRange = l.ProductSpecOutOfRange, }).ExpandAll()) .Concat(new[] { Projector <Lot> .To(l => new LotQualitySummaryReturn { CustomerAllowances = l.CustomerAllowances.Select(a => customerAllowance.Invoke(a)), CustomerOrderAllowances = l.SalesOrderAllowances.Select(a => customerOrderAllowance.Invoke(a)), ContractAllowances = l.ContractAllowances.Select(a => contractAllowance.Invoke(a)) }) })); }
internal static IEnumerable <Expression <Func <ChileLot, LabReportChileLotReturn> > > SplitSelectLabReportChileLot(IQueryable <ProductionBatch> productionBatches, IQueryable <LotProductionResults> lotProdcutionResuls, IQueryable <ChileLotProduction> chileLotProduction) { var chileProductKey = ProductProjectors.SelectProductKey(); var packSchedule = PackScheduleProjectors.SelectBaseWithCustomer(); var productionResult = LotProductionResultsProjectors.SelectBase(); var attribute = LotAttributeProjectors.Select <WeightedLotAttributeReturn>(); var lotTotes = PickedInventoryItemProjectors.SelectPickedLot(); var customerAllowance = LotCustomerAllowanceProjectors.Select(); return(new[] { SelectLotBase().Merge(Projector <ChileLot> .To(c => new LabReportChileLotReturn { LoBac = c.AllAttributesAreLoBac }), c => c.Lot).ExpandAll(), Projector <ChileLot> .To(c => new LabReportChileLotReturn { UnresolvedDefects = c.Lot.LotDefects.Where(d => d.Resolution == null).Select(d => d.Description), WeightedAttributes = c.Lot.Attributes.Select(a => attribute.Invoke(a)), CustomerAllowances = c.Lot.CustomerAllowances.Select(a => customerAllowance.Invoke(a)) }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { WeightedAttributes = c.Lot.Attributes.Select(a => new WeightedLotAttributeReturn { HasResolvedDefects = c.Lot.AttributeDefects.Any(d => d.AttributeShortName == a.AttributeShortName) && c.Lot.AttributeDefects.Where(d => d.AttributeShortName == a.AttributeShortName).All(d => d.LotDefect.Resolution != null) }) }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { ChileProductKeyReturn = chileProductKey.Invoke(c.ChileProduct.Product), PackScheduleBaseReturn = productionBatches.Where(b => b.LotDateCreated == c.LotDateCreated && b.LotDateSequence == c.LotDateSequence && b.LotTypeId == c.LotTypeId) .Select(b => packSchedule.Invoke(b.PackSchedule)).FirstOrDefault() }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { ProductionResultBaseReturn = lotProdcutionResuls.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId) .Select(r => productionResult.Invoke(r)).FirstOrDefault(), PickedLots = chileLotProduction.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId) .SelectMany(r => r.PickedInventory.Items.Select(i => lotTotes.Invoke(i))) }) }); }