Exemplo n.º 1
0
        internal static Expression <Func <Customer, int, CustomerWithProductSpecReturn> > SelectProductSpec()
        {
            var specSelect = CustomerProductAttributeRangeProjectors.Select();
            var keySelect  = SelectKey();

            return((c, p) => new CustomerWithProductSpecReturn
            {
                CustomerName = c.Company.Name,
                CustomerKeyReturn = keySelect.Invoke(c),
                AttributeRanges = c.ProductSpecs.Where(s => s.ChileProductId == p).Select(s => specSelect.Invoke(s))
            });
        }
Exemplo n.º 2
0
        internal static Expression <Func <Customer, IEnumerable <CustomerChileProductAttributeRangesReturn> > > SelectProductSpecs(bool onlyActive = false)
        {
            var customerKey = SelectKey();
            var productKey  = ProductProjectors.SelectChileProductSummary();
            var rangeSelect = CustomerProductAttributeRangeProjectors.Select();

            return(Projector <Customer> .To(c => c.ProductSpecs
                                            .Where(r => r.Active || !onlyActive)
                                            .GroupBy(r => r.ChileProduct)
                                            .Select(g => new CustomerChileProductAttributeRangesReturn
            {
                CustomerKeyReturn = customerKey.Invoke(c),
                ChileProduct = productKey.Invoke(g.Key),
                AttributeRanges = g.Select(r => rangeSelect.Invoke(r))
            })));
        }