我有2个相关的表,它们是
定时
SlotId
Description
Amount
和广告位
Id
Name
示例数据:
时间表
slotid description amount
--------------------------------
1 Morning charge 300
1 Late fee 300
1 Earlier bonus 200
1 Half day 150
2 Morning charge 300
2 Late fee 300
2 Earlier bonus 200
2 Half day 150
3 Morning charge 300
3 Late fee 300
3 Earlier bonus 200
3 Half day 150
最终结果需要SlotSchedules
列表,如下所示:
SlotId
SlotName
List<Schedules>
我需要:
这是我尝试使用LINQ:
List<Schedules> schedulesAll = (from n in dbContext.Schedules
select n).ToList();
var slotsdistinct = schedulesAll.Select(x => x.SlotId).Distinct().ToList();
foreach (var slot in slotsdistinct)
{
var scheduledforslot = schedulesAll.Where(x => x.SlotId == slot).Select(x => x).ToList();
foreach (Schedules _schedule in scheduledforslot)
{
//ListModel.Add(new DetailsModel { Name = _schedule.Description, Amount = (_schedule.Amount });
}
}
任何方法都可以在单个LINQ查询中使用它?
答案 0 :(得分:0)
试试这个:
resp.then(resp => resp.json())
.then(json => {
yield put({ type: UPDATE_DASHBOARD_CHART, charts: json });
});