예제 #1
0
        /// <summary>
        /// Create a new query to rewrite.
        /// </summary>
        /// <param name="query">The actual query.</param>
        /// <param name="provider">The provider to rewrite the query.</param>
        protected RewriteAsyncQueryable(IAsyncQueryable query, RewriteAsyncQueryProvider provider)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (provider == null)
            {
                throw new ArgumentNullException(nameof(provider));
            }

            Query    = query;
            Provider = provider;
        }
예제 #2
0
        /// <summary>
        /// Rewrite a given query.
        /// </summary>
        /// <typeparam name="T">The type of the query data.</typeparam>
        /// <param name="value">The query to rewrite.</param>
        /// <param name="rewriter">The rewriter to rewrite the query.</param>
        /// <returns>The rewritten query.</returns>
        public static IOrderedAsyncQueryable <T> AsyncRewrite <T>(this IOrderedAsyncQueryable <T> value, ExpressionVisitor rewriter)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (rewriter == null)
            {
                throw new ArgumentNullException(nameof(rewriter));
            }

            var provider = new RewriteAsyncQueryProvider(value.Provider, rewriter);

            return(new RewriteAsyncQueryable <T>(value, provider));
        }
예제 #3
0
        /// <summary>
        /// Rewrite a given query.
        /// </summary>
        /// <param name="value">The query to rewrite.</param>
        /// <param name="rewriter">The rewriter to rewrite the query.</param>
        /// <returns>The rewritten query.</returns>
        public static IOrderedAsyncQueryable AsyncRewrite(this IOrderedAsyncQueryable value, ExpressionVisitor rewriter)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (rewriter == null)
            {
                throw new ArgumentNullException(nameof(rewriter));
            }

            var provider = new RewriteAsyncQueryProvider(value.Provider, rewriter);

            return((IOrderedAsyncQueryable)Activator.CreateInstance(
                       typeof(RewriteAsyncQueryable <>).MakeGenericType(value.ElementType),
                       value, provider));
        }