public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Bind(this.Pager.CurrentPageIndex*this.Pager.PageSize, this.Pager.PageSize);
            }
        }
        public void Bind(int CurrentPage,int PageSize)
        {
              using(NorthWindDataContext nor = new NorthWindDataContext())
                {       
                    var result = from c in nor.Customers
                         join o in nor.Orders
                         on c.CustomerID equals o.CustomerID
                         into custorder
                         from o in custorder
                         select new
                         {
                             Customer = c.CompanyName,
                             OrderDate = o.OrderDate,
                             OrderTotal = o.Order_Details.Sum(p => p.UnitPrice)
                         };
                  
                 this.Pager.RecordCount = result.Count();
                 this.GridView1.DataSource = result.Skip(CurrentPage).Take(PageSize);
                 this.GridView1.DataBind();
                 
              }
        }        protected void Pager_PageChanged(object sender, EventArgs e)
        {
            Bind(this.Pager.CurrentPageIndex*this.Pager.PageSize, this.Pager.PageSize);
        }
    }使用了AspNetPager 现在报错为 
此提供程序只支持对返回实体或投影(包含所有标识列)的有序查询使用 Skip(),这种查询为单表(非联接)查询,或者为 Distinct、Except、Intersect 或 Union (非 Concat)操作。 

解决方案 »

  1.   

    提示信息告诉:
    只能在单表,或者Distinct、Except、Intersect 或 Union (非 Concat)操作。才可以用Skip();
    你的这句this.GridView1.DataSource = result.Skip(CurrentPage).Take(PageSize);
    报错..你用join的问题吧??
      

  2.   


     var result = from c in nor.Customers
                             join o in nor.Orders
                             on c.CustomerID equals o.CustomerID
                             into custorder
                             from o in custorder
                             select new
                             {
                                 Customer = c.CompanyName,
                                 OrderDate = o.OrderDate,
                                 OrderTotal = o.Order_Details.Sum(p => p.UnitPrice)
                             };这样不能用Skip?那要分页如何写?