예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
파일: Program.cs 프로젝트: fenixio/Artisan
        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);
        }
예제 #4
0
        /// <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);
        }