示例#1
0
        public int Delete()
        {
            //return 1;
            var dateTime = DateTime.Now.AddHours(-1);
            var id       = DependencyInjectionFactory.CreateContextInstance().Set <DeletedCachedRecord>().Where(item => item.DeletionDateTime < dateTime).Delete();
            List <DeletedCachedRecord> NetCache;

            if (string.IsNullOrWhiteSpace(CacheKey))
            {
                Func <IQueryable <DeletedCachedRecord>, IQueryable <DeletedCachedRecord> > funcCache = AllCache;
                CacheKey = funcCache.Method.GetHashCode().ToString();
            }

            if (CacheService.TryGetCache <List <DeletedCachedRecord> >(CacheKey, out NetCache))
            {
                NetCache.RemoveAll(item => item.DeletionDateTime < dateTime);
            }
            else
            {
                //throw new Exception("CacheManagementRepository on delete method has a exception...");
            }

            return(id);
        }