示例#1
0
 /// <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());
 }
示例#2
0
 /// <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());
     }
 }
示例#3
0
        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());
        }
示例#4
0
        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);
        }
示例#5
0
        /// <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());
        }
示例#6
0
 public IEnumerable <TModel> GetAllCache(int dataType)
 {
     return(AllCache.Where(b => b.DataType == dataType));
 }