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))); }
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())); }
public TResult Execute <TResult>(Expression expression) { WrapperVisitor visitor = new WrapperVisitor(Context); return(InnerQueryProvider.Execute <TResult>(visitor.Visit(expression))); }
public object Execute(Expression expression) { WrapperVisitor visitor = new WrapperVisitor(Context); return(InnerQueryProvider.Execute(visitor.Visit(expression))); }