示例#1
0
        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);
            }
        }
示例#2
0
        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;
            }
        }