我有一个门列表,如下所示:
DoorId DoorName ControllerId ControllerName
------ -------- ------------ --------------
Door1 DoorOne C1 C1
Door2 DoorTwo C1 C1
Door3 DoorThree C2 C2
我需要像这样格式化:
var doorsForSite = new[]
{
new { ControllerId ="C1",ControllerName="C1",IsChecked = "false",
Doors = new[]
{
new { DoorId="Door1",DoorName="DoorOne",Schedules = scheduleList},
new { DoorId="Door2",DoorName="DoorTwo",Schedules = scheduleList},
}
},
new { ControllerId ="C2",ControllerName="C2",IsChecked = "false",
Doors = new[]
{
new { DoorId= "Door3",DoorName="DoorThree",Schedules = scheduleList}
}
}
};
这是按ControllerId
和ControllerName
分组,然后构建Doors
数组。
怎么做?