public static IEnumerable <EFDbContext> GetAllEFDbContext() { HttpContext context = HttpContext.Current; if (context != null && context.Session != null) { EFDbContextStorage ctxStorage = context.Session[STORAGE_KEY] as EFDbContextStorage; return(ctxStorage.GetAllDbContexts()); } else { return(null); } }
public static void AddEFDbContextToStore(string key, EFDbContext dbContext) { HttpContext context = HttpContext.Current; if (context != null && context.Session != null) { if (!(context.Session[STORAGE_KEY] is EFDbContextStorage ctxStorage)) { ctxStorage = new EFDbContextStorage(); } ctxStorage.SetEFDbContextForKey(key, dbContext); context.Session[STORAGE_KEY] = ctxStorage; } }