project0/Business/Business.cs
/// <summary>
/// Use LINQ to eagerly collect all the Order objecsts for a given customer.
/// Collect Item info for all orders
/// </summary>
Use LINQ to eagerly collect all the Order objecsts for a given customer.
Collect Item info for all orders
Use LINQ to eagerly collect all the Order objecsts for a given customer . Collect Item info for all orders
public IEnumerable<Order> orderHistoryByCustomerId(int customerId) {
      if (doesExistCustomerById(customerId)) {
        return (IEnumerable<Order>) ((DbSet<Customer>)Customers)
        .Where(x => x.Id == customerId)
        .Include(c => c.Orders).ThenInclude(o => o.OrderItems).ThenInclude(oi => oi.Item)
        .First().Orders.ToList();
      }
      else {
        throw new ArgumentException("Customer Id not found.");
      }
    }
public IEnumerable < Order > orderHistoryByCustomerId ( int customerId ) { if ( doesExistCustomerById ( customerId ) ) { return ( IEnumerable < Order > ) ( ( DbSet < Customer > ) Customers ) . Where ( x => x . Id == customerId ) . Include ( c => c . Orders ) . ThenInclude ( o => o . OrderItems ) . ThenInclude ( oi => oi . Item ) . First ( ) . Orders . ToList ( ) ; } else { throw new ArgumentException ( " " ) ; } }
Use LINQ to eagerly collect all the Order objecsts for a given customer.
Use LINQ to eagerly collect all the Order objecsts for a given customer .
//return from order in context.Order where order.CustomerId == customerId select order;
customerId
int