Пример #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);
        }
Пример #2
0
 public void CreateSqlTriggerForDetectingDeletedRecords(string tableName, string pK)
 {
     DependencyInjectionFactory.CreateContextInstance().Database.ExecuteSqlCommand(string.Format(QueryToCreateTriggerForDeletedRecords, tableName, DateTime.Now.ToString(), pK));
 }