project0/Business/Business.cs
/// <summary>
/// Use LINQ to eagerly collect all the Order objects for a given location.
/// Collect Item info for all orders
/// </summary>
Use LINQ to eagerly collect all the Order objects for a given location.
Collect Item info for all orders
Use LINQ to eagerly collect all the Order objects for a given location . Collect Item info for all orders
public IEnumerable<Order> orderHistoryByLocationId(int locationId) {
      if (doesExistLocationById(locationId)) {
        return (IEnumerable<Order>) ((DbSet<Location>)Locations)
        .Where(x => x.Id == locationId)
        .Include(l => l.Orders).ThenInclude(o => o.OrderItems).ThenInclude(oi => oi.Item)
        .First().Orders.ToList();
      } else {
        throw new ArgumentException("Location Id not found.");
      }
    }
public IEnumerable < Order > orderHistoryByLocationId ( int locationId ) { if ( doesExistLocationById ( locationId ) ) { return ( IEnumerable < Order > ) ( ( DbSet < Location > ) Locations ) . Where ( x => x . Id == locationId ) . Include ( l => l . Orders ) . ThenInclude ( o => o . OrderItems ) . ThenInclude ( oi => oi . Item ) . First ( ) . Orders . ToList ( ) ; } else { throw new ArgumentException ( " " ) ; } }
Use LINQ to eagerly collect all the Order objects for a given location.
Use LINQ to eagerly collect all the Order objects for a given location .
//return from order in context.Order where order.LocationId == locationId select order;
locationId
int