0
我想通過從控制器到的局部視圖的查詢(JSON)的結果,這就是爲什麼我創建了一個強類型如下:無法轉換類型AnonymousType?
public class Suivi_Client
{
public string ClientID { get; set; }
public string Activite { get; set; }
public string ClientName { get; set; }
}
// list
public class Suivis
{
public List<Suivi_Client> List_Clients { set; get; }
}
然後局部視圖:
@model IEnumerable<Project.Models.Suivi_Client>
<html>
<body>
<table border=1>
<thead>
<tr>
<th>
ID
</th>
<th>
Name
</th>
<th>
Activite
</th>
</tr>
</thead>
@foreach(var item in Model){
foreach (var pop in item.List_Clients)
{
<tr>
<td >
@Html.DisplayFor(modelItem => pop.ClientID)
</td>
< <td >
@Html.DisplayFor(modelItem => pop.ClientName)
</td>
<td >
@Html.DisplayFor(modelItem => pop.Activite)
</td>
</tr>
}
}
</table>
</body>
</html>
這裏是操作方法:
public ActionResult Partial_suivi(string clients)
{
IEnumerable<Suivis> PopModel;
var activit = (from x in frh.productivites
join y in frh.Clients on x.action equals y.ClientName
where x.action.Equals(clients)
select new { x.actionID,x.Activité,y.ClientName,y.Responsable,y.TempsCible,x.tempsmoy_ }).Distinct().ToArray();
PopModel = activit;
return PartialView(PopModel);
}
但我有此錯誤:無法將類型 'AnonymousType#1 []' 到「Project.Models.Suivis
我該如何解決這個錯誤?