日期:2014-05-17  浏览次数:20483 次

遇到这个错误:无法从用法中推导出方法
无法从用法中推导出方法“System.Web.Mvc.WebPage.GetPageList<T>(System.Linq.IOrderedQueryable<T>, int, int)”的类型实参。请尝试显式指定类型实参。
D:\项目练习\MvcTest\MvcApplication\MvcApplication\Areas\AdminManage\Controllers\AppLogoController.cs

下面是我的代码,我都贴出来了

Service
C# code

public IList<web_AppLogo> list()
        {
            try
            {
                var data = db.web_AppLogo.ToList();
                return data;
            }
            catch (Exception)
            {
                return null;
            }
        }



IService
C# code

public interface IAppLogoService
    {
        IList<web_AppLogo> list();
    }


Controller
C# code

public ActionResult List(int? id, int? Page)
        {
            var data = service.list();
            int PageSize = 10;
            int PageIndex = Page ?? 1;
            if (PageIndex < 1) PageIndex = 1;

            ViewData["PageIndex"] = PageIndex;
            ViewData["PageSize"] = PageSize;
            ViewData["ReCordCount"] = data.Count();
            return View(WebPage.GetPageList(data, PageIndex, PageSize));
        }



这是分页的一个cs
C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Text;

namespace System.Web.Mvc
{
    public static class WebPage
    {
        public static IQueryable<T> GetPageList<T>(IOrderedQueryable<T> List, int PageIndex, int PageSize)
        {
            int PageCount = GetPageCount(PageSize, List.Count());
            PageIndex = CheckPageIndex(PageIndex, PageCount);
            return List.Skip((PageIndex - 1) * PageSize).Take(PageSize);
        }

        public static int GetPageCount(int PageSize, int recordCount)
        {
            int PageCount = recordCount % PageSize == 0 ? recordCount / PageSize : recordCount / PageSize + 1;
            if (PageCount < 1) PageCount = 1;
            return PageCount;
        }

        public static int CheckPageIndex(int PageIndex, int PageCount)
        {
            if (PageIndex > PageCount) PageIndex = PageCount;
            if (PageIndex < 1) PageIndex = 1;
            return PageIndex;
        }

        public enum WebPageMode { Normal, Numeric, GroupNumeric }
        public static MvcHtmlString ShowWebPage(this HtmlHelper Html, string urlFormat, int PageIndex, int PageSize, int recordCount, WebPageMode Mode)
        {
            urlFormat = urlFormat.Replace("%7B0%7D", "{0}");
            int PageCount = GetPageCount(PageSize, recordCount);

            StringBuilder TempHtml = new StringBuilder();
            TempHtml.AppendFormat("总共{0}条记录,共{1}页,当前第{2}页&nbsp;&nbsp;", recordCount, PageCount, PageIndex);
            if (PageIndex == 1)
            {
                TempHtml.Append("首页&nbsp;上一页&nbsp;");
            }
            else
            {
                TempHtml.AppendFormat("<a href=\"{0}\">首页</a>&nbsp;", string.Format(urlFormat, 1))
                    .AppendFormat("<a href=\"{0}\">上一页</a>&nbsp;", string.Format(urlFormat, PageIndex - 1));
            }
            // 数字分页
            switch (Mode)
            {
                case WebPageMode.Numeric: