internal long GetCount <TEntity>(Expression <Func <TEntity, bool> > filter, Func <long> func) where TEntity : class
        {
            long?result = null;

            //1.判断是否在二级TableCache,如果没有,则进行二级缓存初始化逻辑
            if (DbContext.OpenTableCache)
            {
                result = TableCacheManager.GetEntitiesFromCache(filter)?.Count;
            }

            //2.判断是否在一级QueryCahe中
            if (DbContext.OpenQueryCache)
            {
                if (result == null)
                {
                    result = QueryCacheManager.GetEntitiesFromCache <long?>();
                }
            }

            //3.如果都没有,则直接从逻辑中获取
            if (result == null || result == default(long))
            {
                result = func();
                DbContext.IsFromCache = false;
                //4.Query缓存存储逻辑(内涵缓存开启校验)
                QueryCacheManager.CacheData(result);
            }

            return(result ?? default(long));
        }
        internal List <TEntity> GetEntities <TEntity>(Expression <Func <TEntity, bool> > filter, Func <List <TEntity> > func) where TEntity : class
        {
            List <TEntity> entities = null;

            //1.判断是否在二级TableCache,如果没有,则进行二级缓存初始化逻辑
            if (DbContext.OpenTableCache)
            {
                entities = TableCacheManager.GetEntitiesFromCache(filter);
            }

            //2.判断是否在一级QueryCahe中
            if (DbContext.OpenQueryCache)
            {
                if (entities == null || !entities.Any())
                {
                    entities = QueryCacheManager.GetEntitiesFromCache <List <TEntity> >();
                }
            }

            //3.如果都没有,则直接从逻辑中获取
            if (entities == null || !entities.Any())
            {
                entities = func();
                DbContext.IsFromCache = false;
                //4.Query缓存存储逻辑(内涵缓存开启校验)
                QueryCacheManager.CacheData(entities);
            }

            return(entities);
        }
        internal T GetObject <T>(Func <T> func) where T : class
        {
            T result = null;

            //1.判断是否在一级QueryCahe中
            if (DbContext.OpenTableCache)
            {
                result = QueryCacheManager.GetEntitiesFromCache <T>();
            }

            //2.如果都没有,则直接从逻辑中获取
            if (result == null)
            {
                result = func();
                DbContext.IsFromCache = false;
                //3.Query缓存存储逻辑(内涵缓存开启校验)
                QueryCacheManager.CacheData(result);
            }

            return(result);
        }