Beispiel #1
0
        public static NewsPressCategory GetByID(int NewsPressCategoryID, IEnumerable <string> includeList = null)
        {
            NewsPressCategory obj = null;
            string            key = cacheKeyPrefix + NewsPressCategoryID + GetCacheIncludeText(includeList);

            NewsPressCategory tmpClass = null;

            if (Cache.IsEnabled)
            {
                if (Cache.IsEmptyCacheItem(key))
                {
                    return(null);
                }
                tmpClass = Cache[key] as NewsPressCategory;
            }

            if (tmpClass != null)
            {
                obj = tmpClass;
            }
            else
            {
                using (Entities entity = new Entities())
                {
                    IQueryable <NewsPressCategory> itemQuery = AddIncludes(entity.NewsPressCategory, includeList);
                    obj = itemQuery.FirstOrDefault(n => n.NewsPressCategoryID == NewsPressCategoryID);
                }
                Cache.Store(key, obj);
            }

            return(obj);
        }
Beispiel #2
0
 public NewsPressCategory(NewsPressCategory objectToCopy)
 {
     Active                    = objectToCopy.Active;
     DisplayOrder              = objectToCopy.DisplayOrder;
     Name                      = objectToCopy.Name;
     NewsPressCategoryID       = objectToCopy.NewsPressCategoryID;
     NewsPressParentCategoryID = objectToCopy.NewsPressParentCategoryID;
 }