0
我有一個UI中的對象數組發送到MVC控制器。對象數組是這樣的:如何發送數組項從UI到MVC控制器
`DoorId`,`DoorName` and an array of `Schedules`. `Schedules` array has `ScheduleId` and `ScheduleName`.
現在如何將它發送到MVC控制器?那麼,每個DoorId
及其關聯的ScheduleId
都可以分別提取以形成另一個對象?
目前,我送了DoorId
陣列和單獨的ScheduleId
陣列,
但我並不想這樣做。我想發送整個陣列本身。
public async Task<ActionResult> AddGroup(string[] DoorIds, string[] scheduleEntity)//AccessGroupEntity entity, string accountId
{
GroupEntity groupEntity = new GroupEntity();
var doorScheduleList = new List<DoorInfoEntity>();
for(int i=0;i< DoorIds.Length;i++)
{
doorScheduleList.Add(new DoorInfoEntity()
{
DoorId = DoorIds[i],
ScheduleId = scheduleEntity[i]
});
}
accessGroupEntity.DoorItems = doorScheduleList;
,然後解析它作爲Doors[index].DoorId
和Doors[index].ScheduleId
以形成「DoorInfoEntity`對象。
怎麼辦?我試過object[] Doors
,但它說Object does not contain a definition for DoorId or ScheduleId
。