Beispiel #1
0
            private static Func <TIn, TOut> CompileFromFingerprint(Expression <Func <TIn, TOut> > expr)
            {
                var fingerprint = FingerprintingExpressionVisitor.GetFingerprintChain(expr, out var capturedConstants);

                if (fingerprint != null)
                {
                    var del = _fingerprintedCache.GetOrAdd(fingerprint, _ =>
                    {
                        // Fingerprinting succeeded, but there was a cache miss. Rewrite the expression
                        // and add the rewritten expression to the cache.
                        var hoistedExpr = HoistingExpressionVisitor <TIn, TOut> .Hoist(expr);
                        return(hoistedExpr.Compile());
                    });
                    return(model => del(model, capturedConstants));
                }

                // couldn't be fingerprinted
                return(null);
            }