天天看點

從緩存中讀取DataTable

從緩存中讀取DataTable
從緩存中讀取DataTable

Code

        /// <summary>

        /// 從緩存中讀取DataTable

        /// </summary>

        /// <param name="cacheKey">cache key</param>

        /// <param name="strWhere">SQL語句條件</param>

        /// <returns></returns>

        /// <date>

        /// 2009-04-21建立

        /// </date>

        public static DataTable BuildDataTable(string cacheKey, string strWhere)

        {

            DataTable dt=null;

            Cache cache = HttpRuntime.Cache; 

            if (cache[cacheKey] != null)

            {

                dt = (DataTable)cache[cacheKey];

            }

            else

            {

                dt = GetDtFromDataBase(strWhere); 

            }

            cache.Insert(cacheKey, dt, null, DateTime.Now.AddMinutes(30), TimeSpan.Zero);

            return dt;

        }

轉載于:https://www.cnblogs.com/cry/archive/2009/04/22/1440945.html