Exemplo n.º 1
0
        /// <summary>
        /// 分页获取新闻信息
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="pagesize">页面大小</param>
        /// <param name="count">总条目</param>
        /// <returns></returns>
        public static List<News> GetPagedNews(int index, int pagesize, ref int count)
        {
            string sql = "select * from News order by Rank desc limit {0} offset {1}";

            using (var db = new SCenterEntities())
            {
                count = db.News.Count();
                return db.ExecuteStoreQuery<News>(sql, new object[] { pagesize, (index - 1) * pagesize }).OrderByDescending(n => n.Rank).ToList();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分页获取公告信息
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="pagesize">页面大小</param>
        /// <param name="cid">类别ID</param>
        /// <param name="count">总条目</param>
        /// <returns></returns>
        public static List<ArticleWithAthmt> GetPagedItems(int index, int pagesize, int cid, ref int count)
        {
            string sql = "select * from ArticleWithAthmt where Sid={0} order by PostTIme desc limit {1} offset {2}";

            using (var db = new SCenterEntities())
            {
                count = db.ArticleWithAthmts.Where(n => n.Sid == cid).Count();
                return db.ExecuteStoreQuery<ArticleWithAthmt>(sql, new object[] { cid, pagesize, (index - 1) * pagesize }).OrderByDescending(n => n.PostTime).ToList();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 分页获取公告信息
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="pagesize">页面大小</param>
        /// <param name="pid">父类类别ID</param>
        /// <param name="count">总条目</param>
        /// <returns></returns>
        public static List<ArticleWithAthmt> GetPagedItemsUsingParentType(int index, int pagesize, int pid, ref int count)
        {
            using (var db = new SCenterEntities())
            {
                string strcid = "";
                var list = db.SystemCategories.Where(s => s.ParentNo == pid).ToList();
                if (list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        strcid += item.Sid + ",";
                        count += db.ArticleWithAthmts.Where(a => a.Sid == item.Sid).Count();
                    }
                }
                if (strcid.Length > 0)
                {
                    strcid = strcid.Substring(0, strcid.Length - 1);
                }
                string sql = "select * from ArticleWithAthmt where Sid in (" + strcid +") order by PostTIme desc limit {0} offset {1}";

                return db.ExecuteStoreQuery<ArticleWithAthmt>(sql, new object[] { pagesize, (index - 1) * pagesize }).OrderByDescending(n => n.PostTime).ToList();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 分页获取公告信息
        /// </summary>
        /// <param name="pid">父类类别ID</param>
        /// <returns></returns>
        public static List<ArticleWithAthmt> GetTopItemsByParentId(int pid, int top)
        {
            using (var db = new SCenterEntities())
            {
                string strcid = "";
                var list = db.SystemCategories.Where(s => s.ParentNo == pid).ToList();
                if (list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        strcid += item.Sid + ",";
                    }
                }
                if (strcid.Length > 0)
                {
                    strcid = strcid.Substring(0, strcid.Length - 1);
                }
                string sql = "select * from ArticleWithAthmt where Sid in (" + strcid + ") order by PostTIme desc";

                return db.ExecuteStoreQuery<ArticleWithAthmt>(sql, new object[] { }).Take(top).OrderByDescending(n => n.PostTime).ToList();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 分页获取总文章信息
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="pagesize">页面大小</param>
        /// <param name="count">总条目</param>
        /// <returns></returns>
        public static List<Article> GetPagedItems(int index, int pagesize,  ref int count)
        {
            string sql = "select * from Article order by PostTIme desc limit {0} offset {1}";

            using (var db = new SCenterEntities())
            {
                count = db.Articles.Count();
                return db.ExecuteStoreQuery<Article>(sql, new object[] { pagesize, (index - 1) * pagesize }).ToList();
            }
        }