Ejemplo n.º 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)));
        }
Ejemplo n.º 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));
        }
        IEnumerator IEnumerable.GetEnumerator()
        {
            WrapperVisitor visitor = new WrapperVisitor(Provider.Context);

            return(new WrappedEnumerator <T, M>(Provider.InnerQueryProvider.CreateQuery <M>(visitor.Visit(Expression)).GetEnumerator()));
        }
Ejemplo n.º 4
0
        public TResult Execute <TResult>(Expression expression)
        {
            WrapperVisitor visitor = new WrapperVisitor(Context);

            return(InnerQueryProvider.Execute <TResult>(visitor.Visit(expression)));
        }
Ejemplo n.º 5
0
        public object Execute(Expression expression)
        {
            WrapperVisitor visitor = new WrapperVisitor(Context);

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