[Back]

using System.Linq;
using System.Web;
using System.Web.Caching;

namespace ADefWebserver.Modules.CategoryAdmin
{
    public static class CategoriesTable
    {
        #region GetCategoriesTable
        public static IQueryable<AdefWebserverCategory> GetCategoriesTable()
        {
            IQueryable<AdefWebserverCategory> Categories;

            // Get Table out of Cache
            object objCategoriesTable = HttpContext.Current.Cache.Get("CategoriesTable");

            // Is the table in the cache?
            if (objCategoriesTable == null)
            {
                // Get the table from the database
                Categories = GetEntireTable();
                HttpContext.Current.Cache.Add("CategoriesTable", Categories, null, Cache.NoAbsoluteExpiration,
                    Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
            }
            else
            {
                // Use the cache version of the table
                Categories = (IQueryable<AdefWebserverCategory>)objCategoriesTable;
            }

            return Categories;
        }
        #endregion

        #region GetEntireTable
        private static IQueryable<AdefWebserverCategory> GetEntireTable()
        {
            CategoryAdminDALDataContext CategoryAdminDALDataContext = new CategoryAdminDALDataContext();

            IQueryable<AdefWebserverCategory> EntireTable = (from AdefWebserverCategories in CategoryAdminDALDataContext.AdefWebserverCategories
                                                             select AdefWebserverCategories).ToList().AsQueryable();

            return EntireTable;
        }
        #endregion
    }
}


Buy DotNetNuke Modules from Snowcovered

 DotNetNuke Powered!DotNetNuke is a registered trademark of DotNetNuke Corporation.