Nach Ausführung der Anwendung, erhalte ich dieDas Modellelement in das Wörterbuch übergibt vom Typ ist, aber dieses Wörterbuch erfordert ein Modell Artikel vom Typ ‚System.Collections.Generic.IEnumerable`1 []‘
The model item passed into the dictionary is of type 'MvcWcfApplication.ServiceReference1.StudentDetail[]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MvcWcfApplication.ServiceReference1.ServiceClient].
Im Hinblick
@model IEnumerable<MvcWcfApplication.ServiceReference1.ServiceClient>
....
<table>
<tr>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
DbController.cs
public class DbController : Controller
{
public ActionResult Index()
{
ServiceReference1.ServiceClient obj = new ServiceReference1.ServiceClient();
return View(obj.GetStudents());
}
}
Mein iService.cs
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService" in both code and config file together.
[ServiceContract]
public interface IService
{
[OperationContract]
List<StudentDetail> GetStudents();
Die Fehlermeldung ist selbsterklärend. Sie rufen einen Service auf, der 'List zurückgibt und übergibt ihn an eine View, die 'IEnumerable ' erwartet - 'StudentDetail' ist ** nicht **' ServiceClient' –
Versuchen Sie' IEnumerable‘zu 'IEnumerable ' –
llouk
New Fehler Compiler-Fehlermeldung: CS0426: der Typname 'StudentDetail' existiert nicht in der Art 'MvcWcfApplication.ServiceReference1.ServiceClient – Ollivander