public static Expression <Hoisted <TIn, TOut> > Hoist(Expression <Func <TIn, TOut> > expr) { HoistingExpressionVisitor <TIn, TOut> visitor = new HoistingExpressionVisitor <TIn, TOut>(); return(Expression.Lambda < Hoisted <TIn, TOut> >( visitor.Visit(expr.Body), new ParameterExpression[] { expr.Parameters[0], HoistingExpressionVisitor <TIn, TOut> ._hoistedConstantsParamExpr })); }
private static Func <TIn, TOut> CompileFromFingerprint(Expression <Func <TIn, TOut> > expr) { Func <ExpressionFingerprintChain, Hoisted <TIn, TOut> > valueFactory = null; List <object> capturedConstants; ExpressionFingerprintChain fingerprintChain = FingerprintingExpressionVisitor.GetFingerprintChain(expr, out capturedConstants); if (fingerprintChain == null) { return(null); } if (valueFactory == null) { valueFactory = _ => HoistingExpressionVisitor <TIn, TOut> .Hoist(expr).Compile(); } Hoisted <TIn, TOut> del = CachedExpressionCompiler.Compiler <TIn, TOut> ._fingerprintedCache.GetOrAdd(fingerprintChain, valueFactory); return(model => del(model, capturedConstants)); }