/// <summary> /// Get the collection of all stores. The cache is enabled by default. /// </summary> /// <param name="noCache">Bypass the cache</param> /// <param name="refreshCache">Force refresh the cache</param> /// <returns></returns> public StoreSet GetStore(bool noCache, bool refreshCache) { // If no cache the load and return a entity set from the database if (noCache && !refreshCache) { return(LoadStoreSet()); } StoreSet storeSet; var cacheKey = StoreSet.StaticGetCacheKey(); if (!CacheManagerProvider.GetCacheManagerInstance().Contains <StoreSet>(cacheKey) || refreshCache) { // Load the entity set from the database storeSet = LoadStoreSet(); if (storeSet != null) { // Add the entity set to the cache by reading caching parameters from the configuration CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, storeSet, ConfigurationManager.GetCacheExpirationByType( storeSet.GetType())); } } else { storeSet = CacheManagerProvider.GetCacheManagerInstance().Get <StoreSet>(cacheKey); } return(storeSet); }
/// <summary> /// Load all stores from the database based on businessName. /// </summary> /// <param name="businessName"></param> /// <returns></returns> private StoreSet LoadStoreSetFromBusinessName(string businessName) { var storeSet = new StoreSet(); var metaData = new LinqMetaData(); var storeCollection = metaData.Store.Where(s => s.BusinessName == businessName); if (storeCollection.Any()) { storeSet.AddRange(storeCollection.Select(entity => new Store(entity))); } return(storeSet); }
private static void DbTest() { StoreSet<Student> store = new StoreSet<Student>( typeof(SchoolContext) ); Student student = store.FirstOrDefault(t => t.Id == 1, "Enrollments.Course"); //Student student = store.FirstOrDefault(t => t.Id == 1); student.DumpToLog(Level.Info); Student stu2 = new Copier<Student>().Copy(student); stu2.DumpToLog(Level.Warn); }
/// <summary> /// Load all stores from the database. /// </summary> /// <returns></returns> private StoreSet LoadStoreSet() { var storeSet = new StoreSet(); // Get the collection from the ORM data layer var metaData = new LinqMetaData(); IQueryable <StoreEntity> storeOptions = from s in metaData.Store select s; var storeCollection = ((ILLBLGenProQuery)storeOptions).Execute <StoreCollection>(); // Fill the entity set from the data collection if (storeCollection.Count > 0) { storeSet.AddRange(storeCollection.Select(entity => new Store(entity))); } // Return the entity set return(storeSet); }