Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var orders = db.Orders
- .Join(db.Shipments,
- o => o.OrderID,
- s => s.OrderID,
- (o, s) => new { Order = o, Shipment = s })
- .Join(db.LineItems,
- s => s.Shipment.ShipmentID,
- l => l.ShipmentID,
- (s, l) => new { Order = s.Order, Shipment = s.Shipment, LineItem = l })
- .Join(db.StatusTypes,
- s => s.Shipment.StatusTypeID,
- st => st.StatusTypeID,
- (s, st) => new { Order = s.Order, Shipment = s.Shipment, LineItem = s.LineItem, Description = st.ExternalDescription })
- .Where(x => x.Order.AccountID == accountId)
- .GroupBy(x => x.Order.OrderNumber)
- .ToList()
- .Select(
- x => new OrderStatusViewModel
- {
- Date = x.Max(y => y.Order.Created),
- OrderNumber = x.Key,
- Cost = x.Sum(y => y.LineItem.UnitPrice).ToString(),
- Status = x.Max(y => y.Description)
- }
- );
Add Comment
Please, Sign In to add comment