Пример #1
0
        public static Redirect GetByID(int RedirectID, IEnumerable <string> includeList = null)
        {
            Redirect obj = null;
            string   key = cacheKeyPrefix + RedirectID + GetCacheIncludeText(includeList);

            Redirect tmpClass = null;

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

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

            return(obj);
        }
Пример #2
0
 public Redirect(Redirect objectToCopy)
 {
     NewUrl     = objectToCopy.NewUrl;
     OldUrl     = objectToCopy.OldUrl;
     RedirectID = objectToCopy.RedirectID;
 }