Je veux passer les résultats d'une requête (JSON) d'un contrôleur à une vue partielle, c'est pourquoi j'ai créé un typer comme suit:Impossible de convertir le type 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; }
}
Ensuite, la vue partielle:
@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>
est la méthode d'action ici:
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);
}
mais je cette erreur: Impossible de convertir le type 'AnonymousType # 1 []' à « Project.Models.Suivis
comment puis-je résoudre cette erreur?