2016-11-16 22 views
0

が見つかりませ最適なタイプは私は次のように別々の​​という名前の配列を持っていない:暗黙的に型指定された配列のJSONエラー

  var scheduleListAll = await DataService.GetSchedule(Id); 
      scheduleList = scheduleListAll.ScheduleItems; 

そして、私のようなdoorsForSiteという名前の別の配列があります。

  var doorsForSite = new[] 
       { 
       new { ControllerId ="controller1",ControllerName="C1",IsChecked = "false", 
         Doors = new[] 
         { 
          new { DoorId="Door1",DoorName="DoorOne"}, 
          new { DoorId = "Door2", DoorName = "DoorTwo" } 
         }, 
         scheduleList 

        }, 
       new { ControllerId ="controller2",ControllerName="C2",IsChecked = "false", 
         Doors = new[] 
         { 
          new { DoorId= "Door3",DoorName="DoorThree"}, 
          new { DoorId = "Door4", DoorName = "DoorFour" }, 
          new { DoorId = "Door5", DoorName = "DoorFive" }, 
         } 

        } 
      }; 

どのようにしsecondfirst arrayを含めますか?

私が試した:

  var doorsForSite = new[] 
       { 
       new { ControllerId ="controller1",ControllerName="Eagle",IsChecked = "false",new object[] { scheduleList }, 
         Doors = new[] 
         { 
          new { DoorId="Door1",DoorName="DoorOne"}, 
          new { DoorId = "Door2", DoorName = "DoorTwo" } 
         }, 
         scheduleList 

        }, 
       new { ControllerId ="controller2",ControllerName="NetAxis",IsChecked = "false",new object[] { scheduleList }, 
         Doors = new[] 
         { 
          new { DoorId= "Door3",DoorName="DoorThree"}, 
          new { DoorId = "Door4", DoorName = "DoorFour" }, 
          new { DoorId = "Door5", DoorName = "DoorFive" }, 
         } 

        } 
      }; 

をしかし、動作しませんでした。何をすべきか ?

答えて

1

あなたはキーを持っている必要があります、あなたはそこに直接配列を置くことはできません。勤務

{ ControllerId ="controller1",ControllerName="Eagle",IsChecked = "false",new object[] { scheduleList }, 
    Doors = new[] 
    { 
     new { DoorId="Door1",DoorName="DoorOne"}, 
     new { DoorId = "Door2", DoorName = "DoorTwo" } 
    }, 
    ScheduleList = scheduleList //like this 
} 
1

よう

何か。

  var doorsForSite = new[] 
       { 
       new { ControllerId ="controller1",ControllerName="Eagle",IsChecked = "false",Schedules = scheduleList, 
         Doors = new[] 
         { 
          new { DoorId="Door1",DoorName="DoorOne"}, 
          new { DoorId = "Door2", DoorName = "DoorTwo" } 
         } 

        }, 
       new { ControllerId ="controller2",ControllerName="NetAxis",IsChecked = "false", Schedules = scheduleList, 
         Doors = new[] 
         { 
          new { DoorId= "Door3",DoorName="DoorThree"}, 
          new { DoorId = "Door4", DoorName = "DoorFour" }, 
          new { DoorId = "Door5", DoorName = "DoorFive" }, 
         } 

        } 
      }; 
関連する問題