public static IDbContextStorageContainer CreateStorageContainer()
        {
            if (DataContectStorageContainer == null)
            {
                if (HttpContext.Current == null)
                    DataContectStorageContainer = new ThreadDbContextStorageContainer();
                else
                    DataContectStorageContainer = new HttpDbContextStorageContainer();
            }

            return DataContectStorageContainer;
        }
Example #2
0
        public static T GetDbContext()
        {
            IDbContextStorageContainer <T> container = DbContextStorageFactory <T> .CreateStorageContainer();

            var dbContext = container.GetDbContext();

            if (dbContext == null)
            {
                dbContext = new T();
                container.Store(dbContext);
            }
            return(dbContext as T);
        }
 public static IDbContextStorageContainer <T> CreateStorageContainer()
 {
     if (_dbContainer == null)
     {
         if (HttpContext.Current == null)
         {
             _dbContainer = new ThreadDbContextStorageContainer <T>();
         }
         else
         {
             _dbContainer = new HttpDbContextStorageContainer <T>();
         }
     }
     return(_dbContainer);
 }
Example #4
0
        public static void ClearDbContext()
        {
            IDbContextStorageContainer <T> container = DbContextStorageFactory <T> .CreateStorageContainer();

            container.Clear();
        }