예제 #1
0
        public static CompilableProvider Rewrite(
            CompilableProvider originProvider,
            Func <CompilableProvider, ProviderOrderingDescriptor> orderingDescriptorResolver)
        {
            ArgumentValidator.EnsureArgumentNotNull(originProvider, "originProvider");
            var rewriter = new OrderingRewriter(orderingDescriptorResolver);

            if (originProvider.Type == ProviderType.Select)
            {
                var selectProvider = (SelectProvider)originProvider;
                var source         = rewriter.VisitCompilable(selectProvider.Source);
                return(new SelectProvider(
                           rewriter.InsertSortProvider(source),
                           selectProvider.ColumnIndexes));
            }
            var visited = rewriter.VisitCompilable(originProvider);

            return(rewriter.InsertSortProvider(visited));
        }
 /// <inheritdoc/>
 CompilableProvider IPreCompiler.Process(CompilableProvider rootProvider)
 {
     return(OrderingRewriter.Rewrite(rootProvider, orderingDescriptorResolver));
 }