protected void InitializeCaches() { if (!_cachesInitialized) { using (var dbContext = _dbContextFactory.Create()) { _programmeDictionaryCache = new ProgrammeDictionaryCache(dbContext, trackingChanges: false); _programmeDictionaryCache.Load(); _programmeCategoryCache = new ProgrammeCategoryCache(dbContext, trackingChanges: false); _programmeCategoryCache.Load(); _scheduleCache = new SqlServerEntityCache <int, ScheduleEntity>(dbContext, x => x.ScheduleUniqueKey, trackingChanges: false); _scheduleCache.Load(); _salesAreaCache = new SqlServerEntityCache <string, SalesArea>(dbContext, x => x.Name, trackingChanges: false); _salesAreaCache.Load(); _categoryHierarchyNames = new HashSet <string>(dbContext.Query <ProgrammeCategoryHierarchy>().Select(x => x.Name) .AsEnumerable()); } _cachesInitialized = true; } }