[1] У меня есть эта ошибка Элемент модели, переданный в словарь, имеет тип 'System.Collections.Generic.List, но этот словарь
требуется элемент модели типа 'PagedList.IPagedList`1 [OpenOrderFrame
i have my controller as this :
public class ItemsController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
// GET: Items
public ActionResult Index(string sortOrder, string currentFilter, string searchString, int? page)
{
ViewBag.CurrentSort = sortOrder;
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "Name";
ViewBag.PriceSortParm = sortOrder == "Name" ? "Loc_desc" : "Location";
IEnumerable<Item> items = db.Items;
var jo = (from a in items.GroupBy(x => new { x.Catagorie, x.ItemName })
.Select(g => new
{
Category = g.Key.Catagorie,
ItemName = g.Key.ItemName,
Quantity = g.Sum(s => s.ItemQty),
Location = g.First().Location
})
select a);
if (!string.IsNullOrWhiteSpace(searchString))
{
items = items.Where(s => s.ItemName.ToUpper().Contains(searchString.ToUpper())
|| s.Catagorie.Name.ToUpper().Contains(searchString.ToUpper())||
s.Location.Name.ToUpper().Contains(searchString.ToUpper())).ToList().ToPagedList(page ??1, 20);
//}
}
else
{
items = items.ToList().ToPagedList(page ?? 1, 10);
}
return View(jo);
и в моем представлении у меня есть код как это:
@model PagedList.IPagedList<OpenOrderFramework.Models.Item>
@using PagedList.Mvc;
@using PagedList;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
ViewBag.Title = "Food";
}
[2], пожалуйста, помогите мне с кодом, я так сыт по горло
я хочу передать список элементов в jo, чтобы просмотреть страницу .. СПАСИБО