public async Task <Order> GetOrder(int Id) { var order = await _context.Order .FirstOrDefaultAsync(m => m.OrderId == Id); _context.Entry(order).Collection(s => s.Tickets).Load(); foreach (Ticket ticket in order.Tickets) { _context.Entry(ticket).Reference(x => x.Seat).Load(); _context.Entry(ticket).Reference(x => x.Viewing).Load(); _context.Entry(ticket.Viewing).Reference(v => v.Movie).Load(); _context.Entry(ticket.Viewing).Reference(v => v.Salon).Load(); ticket.Viewing.FormatedStartTime = ticket.Viewing.StartTime.ToString("dddd HH:mm"); } return(order); }
public void LoadOrder(Order order) { // _context.Entry(order).Collection(o => o.Tickets).Load(); _context.Entry(order).Reference(o => o.User).Load(); }