/// <summary> /// 获取列表页面的页数 /// </summary> /// <param name="id"></param> protected void GetClassPageCount(int id) { DataEntities ent = new DataEntities(); Class c = ClassAction.Classes.Where(p => p.ID == id).FirstOrDefault(); TemplateHelper h = new TemplateHelper(); TemplateList t = h.GetListTemplate(c); int pagecount = 0; switch (c.ModelID) { case 1: //新闻 pagecount = //NewsView.Count(string.Format("classid in(select {0} union select id from Class where parentID={0})", id)).GetPageCount(t.ShowRecordCount); (from p in ent.Class from cls in ent.Class from l in ent.News where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; case 2: //图片 pagecount = (from p in ent.Class from cls in ent.Class from l in ent.ImageAlbum where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; case 3: //问答 pagecount = (from p in ent.Class from cls in ent.Class from l in ent.Question where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; case 4: //小说 pagecount = (from p in ent.Class from cls in ent.Class from l in ent.Book where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; case 5: //分类 pagecount = (from p in ent.Class from cls in ent.Class from l in ent.Info where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; case 6: //影视 pagecount = (from p in ent.Class from cls in ent.Class from l in ent.MovieInfo where p.ID == id && cls.ParentID == id && (l.ClassID == p.ID || l.ClassID == cls.ID) select l).Count().GetPageCount(t.ShowRecordCount.ToInt32()); break; default: pagecount = 0; break; } ent.Dispose(); Response.Clear(); Response.Write(pagecount); }