コード例 #1
0
        public static IQueryable <T> Wrap <T>(this IQueryable <T> queryable, WrapperContext context)
        {
            if (queryable == null)
            {
                throw new ArgumentNullException(nameof(queryable));
            }
            var visitor = new WrapperVisitor(context);

            return(queryable.Provider.CreateQuery <T>(visitor.Visit(queryable.Expression)));
        }
コード例 #2
0
        public static IQueryable <M> Unwrap <T, M>(this IQueryable <T> queryable, WrapperContext context = null)
            where M : T
        {
            if (queryable == null)
            {
                throw new ArgumentNullException(nameof(queryable));
            }
            WrappedQueryable <T, M> wrapped = queryable as WrappedQueryable <T, M>;

            if (wrapped == null)
            {
                throw new NotSupportedException("不支持的类型。");
            }
            WrappedQueryableProvider <T, M> provider = wrapped.Provider;
            var visitor    = new WrapperVisitor(context ?? provider.Context);
            var expression = visitor.Visit(wrapped.Expression);

            return(provider.InnerQueryProvider.CreateQuery <M>(expression));
        }
コード例 #3
0
        IEnumerator IEnumerable.GetEnumerator()
        {
            WrapperVisitor visitor = new WrapperVisitor(Provider.Context);

            return(new WrappedEnumerator <T, M>(Provider.InnerQueryProvider.CreateQuery <M>(visitor.Visit(Expression)).GetEnumerator()));
        }
コード例 #4
0
        public TResult Execute <TResult>(Expression expression)
        {
            WrapperVisitor visitor = new WrapperVisitor(Context);

            return(InnerQueryProvider.Execute <TResult>(visitor.Visit(expression)));
        }
コード例 #5
0
        public object Execute(Expression expression)
        {
            WrapperVisitor visitor = new WrapperVisitor(Context);

            return(InnerQueryProvider.Execute(visitor.Visit(expression)));
        }