找不到隐式类型数组Json错误的最佳类型

时间:2016-11-16 05:55:30

标签: c# arrays 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" }, } } }; 的数组,如:

first array

如何将second纳入 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" }, } } };

我试过了:

WorkListDal ad = new WorkListDal();
var model = new WorkListEntity()
model.Formid="WorkList";
model.AfterAuditVoid() = ad.WorkListVoid();
InitWorkListDal.DoWork(model)

WorkListDal2 ad2 = new WorkListDal();
var model = new WorkListEntity()
model.Formid="WorkList";
model.AfterAuditVoid() = ad2.OtherVoid();
InitWorkListDal.DoWork(model)

但没有奏效。怎么办?

2 个答案:

答案 0 :(得分: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 :(得分:1)

工作了。

<?php
		
		// SO UPDATE THE QUERY TO ONLY PULL THAT SHOW'S DOGS
		$query = "SELECT c.* , p.* FROM result c,dogs p WHERE c.dog_id=p.dog_id";
	
		
		$result = mysqli_query($connection, $query) or trigger_error
		("Query Failed! SQL: $query - Error: ". mysqli_error
		($connection), E_USER_ERROR);
		
		if ($result) {
		while ($row = mysqli_fetch_assoc($result)) {
		$placement = $row['placement'];
		$classname = $row['class_name'];
		$dog_name = $row['dog_name'];
		$award = $row['award'];
		
		
		
		
		?>
		
		
		<table>
			<tr>
			<td><strong><?php echo $classname ?></strong> </td><br>
			</tr>
			<tr>
			<td><strong><?php echo $placement, $award ?></strong>  <?php echo $dog_name ?></td>	
			</tr>
		</table>
		
		
		
		
		
		
    	

		<?php  }}} ?>