Ejemplo n.º 1
0
        /// <summary>
        /// 根据简单策略来启用缓存。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static EntityMeta EnableClientCache(this EntityMeta meta, ClientCacheScopeType type = ClientCacheScopeType.ScopedByRoot)
        {
            var cs = new ClientCacheScope();
            cs.Class = meta.EntityType;
            cs.SimpleScopeType = type;

            if (type == ClientCacheScopeType.ScopedByRoot && meta.EntityCategory != EntityCategory.Root)
            {
                cs.ScopeClass = meta.AggtRoot.EntityType;
                cs.ScopeIdGetter = e => GetRootId(e as Entity).ToString();
            }

            meta.ClientCacheDefinition = cs;

            return meta;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据简单策略来启用缓存。
        /// </summary>
        /// <param name="meta"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static EntityMeta EnableClientCache(this EntityMeta meta, ClientCacheScopeType type = ClientCacheScopeType.ScopedByRoot)
        {
            var cs = new ClientCacheScope();

            cs.Class           = meta.EntityType;
            cs.SimpleScopeType = type;

            if (type == ClientCacheScopeType.ScopedByRoot && meta.EntityCategory != EntityCategory.Root)
            {
                cs.ScopeClass    = meta.AggtRoot.EntityType;
                cs.ScopeIdGetter = e => GetRootId(e as Entity).ToString();
            }

            meta.ClientCacheDefinition = cs;

            return(meta);
        }