private SqlObjectListCacheInner <TEntity, TKey> GetCacheObj()
        {
            SqlObjectListCacheInner <TEntity, TKey> cacheObj = DynamicCache.Instance.GetData <SqlObjectListCacheInner <TEntity, TKey> >(_CacheKey);

            if (cacheObj == null)
            {
                List <TEntity> items = LoadCacheItems();
                if (items == null)
                {
                    items = new List <TEntity>();
                }

                cacheObj          = new SqlObjectListCacheInner <TEntity, TKey>();
                cacheObj.Items    = items;
                cacheObj.ItemsDic = GetItemsDic(items);

                //加入动态缓存
                //if (this._SqlDependencies == null)
                //{
                //    this._SqlDependencies = this.GetSqlDependencies();
                //}
                //if (this._SqlDependencies == null)
                //{
                //    throw new Exception("GetSqlDependencies is null");
                //}
                SqlDependencyExpiration[] sqlDependencies = GetSqlDependencies();
                DynamicCache.Instance.Add(CacheManagerName.Defalut, _CacheKey, cacheObj, sqlDependencies);

                this.LastLoadTime = DateTime.Now;
            }

            return(cacheObj);
        }
        /// <summary>
        /// 根据指定的键值获取缓存项
        /// </summary>
        public virtual TEntity GetItem(TKey key)
        {
            if (key == null)
            {
                return(null);
            }

            SqlObjectListCacheInner <TEntity, TKey> cacheObj = GetCacheObj();

            TEntity result;

            cacheObj.ItemsDic.TryGetValue(key, out result);
            return(result);
        }
        /// <summary>
        /// 获取所有的缓存项集合
        /// </summary>
        public virtual List <TEntity> GetAll()
        {
            SqlObjectListCacheInner <TEntity, TKey> cacheObj = GetCacheObj();

            return(cacheObj.Items.ToList());
        }