public override void AttachInvalidations(SchemaBuilder sb, InvalidateWith invalidateWith, EventHandler invalidate) { if (CacheLogic.GloballyDisabled) { base.AttachInvalidations(sb, invalidateWith, invalidate); } else { EventHandler <CacheEventArgs> onInvalidation = (sender, args) => { if (args == CacheEventArgs.Invalidated) { invalidate(sender, args); } else if (args == CacheEventArgs.Disabled) { if (Transaction.InTestTransaction) { invalidate(sender, args); Transaction.Rolledback += dic => invalidate(sender, args); } Transaction.PostRealCommit += dic => invalidate(sender, args); } }; foreach (var t in invalidateWith.Types) { CacheLogic.TryCacheTable(sb, t); GetController(t).Invalidated += onInvalidation; } } }
public static FluentInclude <T> WithCache <T>(this FluentInclude <T> fi) where T : Entity { CacheLogic.TryCacheTable(fi.SchemaBuilder, typeof(T)); return(fi); }