示例#1
0
        internal static Expression <Func <IEnumerable <T> > > Rewrite <T>(IndexQueryValues queryValues, Expression queryValuesExpression, Expression expression)
        {
            var enumerableRewriter = new IndexExpressionRewriter(queryValues, queryValuesExpression);
            var body = enumerableRewriter.Visit(expression);

            return(Expression.Lambda <Func <IEnumerable <T> > >(body, null));
        }
 internal IndexExpressionRewriter(IndexQueryValues index, Expression indexExpression)
 {
     _index           = index ?? throw new ArgumentNullException(nameof(index));
     _indexExpression = indexExpression ?? throw new ArgumentNullException(nameof(indexExpression));
     _indexMethods    = new Lazy <ILookup <string, MethodInfo> >(() =>
                                                                 typeof(Index <>).MakeGenericType(index.ElementType).GetMethods(BindingFlags.Instance | BindingFlags.Public).ToLookup(m => m.Name));
 }
示例#3
0
 internal static Func <IEnumerable <T> > Compile <T>(IndexQueryValues queryValues, Expression queryValuesExpression, Expression expression)
 {
     return(Rewrite <T>(queryValues, queryValuesExpression, expression).Compile());
 }