尝试获得一个IEnumerable WorkOrderHeader给定以下表结构:
OrderHeader 1:many OrderDetails
OrderDetail 1:1 WorkOrderHeader
代码:public IEnumerable<WorkOrderHeader> GetInProcessWorkOrdersForOrderBy(OrderHeader orderHeader)
{
var orderDetails = orderHeader.OrderDetails;
var workOrders= orderDetails.Select(od => od.WorkOrderHeaders.Where(woh => woh.StatusId < (int)WorkOrderStatus.Complete));
return workOrders;
}
返回一个嵌套的IEnumerable<IEnumerable<WorkOrderHeader>>
。如何获得内部的IEnumerable<WorkOrderHeader>
?
我想你是在寻找SelectMany
var workOrders= orderDetails.SelectMany(od => ...)