Je reçois cette erreur dans la ligne @foreach(var item in Model)
.LINQ to Entities ne reconnaît pas la méthode
Comment puis-je résoudre ce problème?
LINQ to Entities ne reconnaît pas la méthode 'System.Collections.Generic.List
1[System.Char] ToList[Char](System.Collections.Generic.IEnumerable
1 [System.Char])' méthode , et cette méthode ne peut pas être traduit en une expression de magasin.
Contrôleur
public ActionResult ProductIndex(int pageno= 0)
{
ViewBag.PageNumber= Paging.CountPageNumber(db.Products.Count(), 8);
ViewBag.ActivePageNo= sayfaNo;
var product = db.Products.OrderBy(x =>
x.Name.Skip(pageno* 8).Take(8).ToList());
return View(product);
}
Voir
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Brand</th>
<th>Category</th>
<th>Size</th>
<th>Stock</th>
<th>Active</th>
<th>Edit</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@item.Id</td>
<td class="box-title" data-original-title="click to edit">
@Html.ActionLink(item.Name, "ProductDetails", new { id = item.Id })
</td>
<td>@item.Price</td>
<td>@item.Brand</td>
<td>@item.Category.Name</td>
<td>@item.Size</td>
<td>@item.StockQuantity</td>
@if (item.IsActive)
{
<td>Aktif</td>
}
else
{
<td>Pasif</td>
}
<td>
<a href="../Admin/SupplierEdit/@item.Id">
<i class="fa fa-pencil-square-o"></i>Edit
</a>
@if (item.IsActive)
{
<a href="../Admin/ProductDelete/@item.Id">
<i class="fa fa-minus-circle"></i>Delete
</a>
}
else
{
<a href="../Admin/ProductDelete/@item.Id">
<i class="fa fa-check"></i>Activate
</a>
}
</td>
</tr>
}
merci beaucoup. mon erreur. il fonctionne maintenant. – livefreeor
@livefreeor chose sûre. Si la réponse vous a aidé, je vous serais reconnaissant si vous l'avez marqué comme correct – Jonesopolis