/// <summary> /// 取该类型的对象 /// </summary> /// <param name="type"></param> /// <returns></returns> public List <IDicConfig> Get(string type, bool noCache = false) { if (noCache) { return(QueryList(b => b.DicType == type)); } return(AllCache.Where(b => b.DicType == type).ToList()); }
/// <summary> /// 取对象 /// </summary> /// <param name="id"></param> /// <returns></returns> public IDicConfig Get(int id, bool noCache = false) { if (noCache) { return(QueryItem(b => b.Id == id)); } else { var items = AllCache.Where(b => b.Id == id); return(items.FirstOrDefault()); } }
public Advert QueryItem(int id) { var items = AllCache.Where(b => b.Id == id); if (items.Count() == 0) { var item = new Advert(); item.Title = "尚未添加"; return(item); } return(items.First()); }
public CRL.DicConfig.IDicConfig Get(string type, string dName, bool noCache = false) { IDicConfig dic; if (noCache) { dic = QueryItem(b => b.DicType == type && b.Name == dName); } else { dic = AllCache.Where(b => b.DicType == type && b.Name == dName).FirstOrDefault(); } if (dic == null) { throw new Exception(string.Format("找不到对应的字典 类型:{0} 名称:{1}", type, dName)); } return(dic); }
/// <summary> /// 查询 /// </summary> /// <param name="categoryCode"></param> /// <param name="top"></param> /// <returns></returns> public List <Advert> Query(string categoryCode, int top, bool checkDate = false) { //ParameCollection c = new ParameCollection(); //c.SetQuerySortField("Sort"); //c.SetQuerySortType(true); //c["categoryCode"] = categoryCode; //c["Disable"] = 0; //c.SetCacheTime(10); //c.SetQueryTop(top); //List<IAdvert> list = QueryList<IAdvert>(c); //return list; var time = DateTime.Now; List <Advert> list; if (checkDate) { list = AllCache.Where(b => b.CategoryCode == categoryCode && b.BeginTime <time && b.EndTime> time && b.Disable == false).Skip(0).Take(top).OrderByDescending(b => b.Sort).ToList(); } else { list = AllCache.Where(b => b.CategoryCode == categoryCode && b.Disable == false).Skip(0).Take(top).OrderByDescending(b => b.Sort).ToList(); } return(list.ToList()); }
public IEnumerable <TModel> GetAllCache(int dataType) { return(AllCache.Where(b => b.DataType == dataType)); }