【发布时间】:2021-04-08 01:52:49
【问题描述】:
我没有做太多处理标题和详细记录的工作。我需要创建一个订单对象
并将 IList
var orderHeaderRecords = ctx.sparGetOrderConfirmationRecords_WED(runDate).ToList();
var orderDetailRecords = ctx.sparGetOrderConfirmationRecordsDetail_WED(runDate).ToList();
var order = (from o in orderHeaderRecords
//gave up on join
//join od in orderDetailRecords on new { o.RecordType, o.OrderNumber } equals new { od.RecordType, //od.OrderNumber }
select new OrderConfirmation()
{
BillAddr1 = o.BillToAddr1,
BillAddr2 = o.BillToAddr2,
IsOfficeOrder = Convert.ToBoolean(o.IsOfficeOrder),
OrderConfirmationType = EnumHelper.GetValueFromDescription<ConfirmationType>(o.RecordType),
LineItems = new List<LineItem>()
}).ToList();
order.ForEach(or =>
{ or.LineItems.AddRange((from line in orderDetailRecords.Where(x =>
x.RecordType == or.OrderConfirmationType.ToDescription()
&& x.OrderNumber == or.OrderNumber).Select(od =>
new LineItem(
{
Desc = od.Description,
ExtAmt = od.ExtPrice.Value,
ItemId = od.Item }
).Select(rec => rec).ToList()); //.ToList()));
});
```
The last line of code (body must end with a select or group by)
I just need to get the detail records in the "List" on the master record.
【问题讨论】: