예제 #1
0
        public TEntity Delete(TEntity entity)
        {
            var key = EntityKeyInfo.GetPrimaryKey(entity);

            cacheManager.Remove(key, Region);
            return(entity);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="entity"></param>
        public TEntity Add(TEntity entity)
        {
            var key = EntityKeyInfo.GetPrimaryKey(entity);

            cacheManager.Add(key, entity, Region);
            return(entity);
        }
예제 #3
0
        public TEntity Update(TEntity entity)
        {
            var key = EntityKeyInfo.GetPrimaryKey(entity);

            return(cacheManager.AddOrUpdate(key, Region, entity, (oldValue) =>
            {
                return entity;
            }));
        }
예제 #4
0
 public IEnumerable <TEntity> AddRange(IEnumerable <TEntity> entitiesToAdd)
 {
     foreach (var entity in entitiesToAdd)
     {
         var key = EntityKeyInfo.GetPrimaryKey(entity);
         cacheManager.Add(key, entity, Region);
     }
     return(entitiesToAdd);
 }
예제 #5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dataList"></param>
 /// <param name="periodTime"></param>
 /// <param name="isReplace"></param>
 /// <returns></returns>
 protected bool InitCache(List <TEntity> dataList, bool isReplace)
 {
     Collection.Clear();
     foreach (var data in dataList)
     {
         Collection.Add(EntityKeyInfo.GetPrimaryKey(data), data);
     }
     return(true);
 }