尝试获取具有以下表结构的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>
?
答案 0 :(得分:2)
我认为您正在寻找SelectMany
var workOrders= orderDetails.SelectMany(od => ...)