Beispiel #1
0
        public TJoin Process(TEntity entity)
        {
            ISpecification <TJoin> specification = SpecificationFactory.Create <TJoin>();
            IRepository <TJoin>    repository    = DependencyResolver.Resolve <IRepository <TJoin> >();

            if (repository == null)
            {
                throw new PlatformException("类型 {0} 未实现仓储。", typeof(TJoin).FullName);
            }
            specification = specAction(entity, specification);

            //如果为主键的获取表达式,则使用Get方式。
            object id;

            if (IsIdentityExpression(specification.CriteriaExpression, out id))
            {
                return(repository.Get(specification.ShardParams, id));
            }

            ///缓存查询
            if (metadata.JoinCache.IsCacheable)
            {
                return(repository
                       .Cache()
                       .Depend(metadata.JoinCache.GetCacheRegions(entity))
                       .Proxy()
                       .FindOne(specification));
            }
            return(repository.FindOne(specification));
        }
Beispiel #2
0
        public IEnumerable <TJoin> Process(TEntity entity)
        {
            ISpecification <TJoin> specification = SpecificationFactory.Create <TJoin>();
            IRepository <TJoin>    repository    = DependencyResolver.Resolve <IRepository <TJoin> >();

            if (repository == null)
            {
                throw new PlatformException("类型 {0} 未实现仓储。", typeof(TJoin).FullName);
            }
            specification = specAction(entity, specification);

            // 查询缓存
            if (metadata.JoinCache.IsCacheable)
            {
                return(repository
                       .Cache()
                       .Depend(metadata.JoinCache.GetCacheRegions(entity))
                       .Proxy()
                       .FindAll(specification));
            }

            return(repository.FindAll(specification));
        }