/// <summary> /// 缓存Dictionary<cat_id, NewsCateInfo>对象 /// </summary> /// <returns></returns> public static Dictionary <string, NewsCateInfo> GetNewsCates() { object o = CacheHelper.Cache_Get(Constants.CN_NewsCates_All); var dict = o as Dictionary <string, NewsCateInfo>; if (dict != null && dict.Count > 0) { return(dict); } Dictionary <string, NewsCateInfo> cates; var search = new NewsCateSearchInfo(); List <NewsCateInfo> list = DataAccess_News.NewsCates_SelectPaged(false); cates = new Dictionary <string, NewsCateInfo>(list.Count); list.ForEach(t => { string cat_id = t.cat_id.ToString(); if (!cates.ContainsKey(cat_id)) { cates.Add(cat_id, t); } }); CacheHelper.Cache_Store(Constants.CN_NewsCates_All, cates, TimeSpan.FromMinutes(10)); return(cates); }
/// <summary> /// 获得新闻分类 /// </summary> /// <returns></returns> public static List <NewsCateInfo> NewsCates_SelectPaged(bool isLen = true) { NewsCateSearchInfo search = new NewsCateSearchInfo(); if (isLen) { search.cat_path_len = 2; } int rowcount = 0; using (var access = new DataAccess_QzNews(Constants.QZNewSite_News_Db_Key)) { return(access.NewsCates_SelectPaged("*", search.ToWhereString(), search.DefOrder, 1, UInt16.MaxValue, out rowcount)); } }