コード例 #1
0
 /// <summary>
 /// edit data cache must update
 /// </summary>
 public static void CacheChanges <T>()
 {
     if (IsCache)
     {
         Cache_Helper_DG.Cache_Delete(nameof(T));
     }
 }
コード例 #2
0
 /// <summary>
 /// query cache
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public static IQueryable <T> GetIQuerybleByCache <T>() where T : class
 {
     if (IsCache)
     {
         IQueryable <T> iqueryable = Cache_Helper_DG.Cache_Get(nameof(T)) as IQueryable <T>;
         if (iqueryable == null)
         {
             DbContext db = GetCurrentDbContext();
             iqueryable = db.Set <T>().AsExpandable();
             Cache_Helper_DG.Cache_Add(nameof(T), iqueryable, null, DateTime.Now.AddMinutes(CacheExpirationTime_Minutes), TimeSpan.Zero);
         }
         return(iqueryable);
     }
     else
     {
         DbContext db = GetCurrentDbContext();
         return(db.Set <T>().AsExpandable());
     }
 }