Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 传递到字典的模型项需要“PagedList.IPagedList”类型的模型项_C#_Model View Controller - Fatal编程技术网

C# 传递到字典的模型项需要“PagedList.IPagedList”类型的模型项

C# 传递到字典的模型项需要“PagedList.IPagedList”类型的模型项,c#,model-view-controller,C#,Model View Controller,[1] 我有此错误传递到字典中的模型项的类型为“System.Collections.Generic.List”,但此字典 需要类型为“PagedList.IPagedList`1[OpenOrderFrame]的模型项 i have my controller as this : public class ItemsController : Controller { private ApplicationDbContext db = new Appl

[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中的项目列表传递到查看页面。谢谢你正在返回jo,但你不想返回项目吗


或者让jo成为页面列表…

您将返回此处查看jo Viewjo:

不是IPagedList类型的

看起来您错误地将jo变量而不是items传递回了View方法。将其更改为passed items应该可以解决此问题


旁注:我不确定在创建jo时,您是如何通过对项目执行linq操作的,但后来您又对项目执行了一些操作,并将jo返回。因此,您需要删除额外的代码。

我想返回VarJot中的项目列表。如果您必须将jo设置为PagedList,您可以帮助我吗pleasereturn Viewjo.ToList.ToPagedListpage??1, 10;它抱怨:额外的信息:方法“第一”只能用作最终的查询操作。
 return View(items);
return View(jo);