You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ExpressionExpander.VisitMethodCall; "Invoke"-Resolver (lines 65-85) is not resolving the case that one of the direct arguments in Invoke(..) is a call to another .Invoke.
Example:
System.Linq.Expressions.Expression<Func<string, string[], IEnumerable<string>>> PredicateFoo =
(par1, par2) => par1.Split(par2, StringSplitOptions.None); // Just some stuff
System.Linq.Expressions.Expression<Func<string, string[], IEnumerable<string>>> PredicateInnerInvoke =
(par1, par2) => PredicateFoo.Invoke(par1, par2); // Invoke
System.Linq.Expressions.Expression<Func<string, string[], IEnumerable<string>>> PredicateOuterInvoke =
(par1, par2) => PredicateFoo.Invoke(PredicateInnerInvoke.Invoke(par1, par2).First(), par2); // Invoke(Invoke(..))
var bad = PredicateOuterInvoke.Expand().ToString();
// bad == (par1, par2) => value(xyz+<>c__DisplayClass2).PredicateOuterInvoke.Invoke(par1, par2).First().Split(par2, None)
// There is still a call to .Invoke here; Entity Framework does not know how to handle this
// Expected (no .Invoke anymore):
// good == (par1, par2) => par1.Split(par2, None).First().Split(par2, None)
We resolved this by using the following (very simple & not correct) Expand method:
public static Expression<TDelegate> ExpandEx<TDelegate>(this Expression<TDelegate> expr)
{
while (expr.ToString().Contains(".Invoke"))
{
expr = LinqKit.Extensions.Expand(expr); // Expand will not expand all .Invoke calls, so do it recursively
}
return expr;
}
Our real life example:
Predicate1(X) = Get all users where X
Predicate2(X) = Get all users and their deputies from (Get all users where X)
so we are calling Predicate2.Invoke(Predicate1.Invoke(X)) and this fails.
The text was updated successfully, but these errors were encountered:
ExpressionExpander.VisitMethodCall; "Invoke"-Resolver (lines 65-85) is not resolving the case that one of the direct arguments in Invoke(..) is a call to another .Invoke.
Example:
We resolved this by using the following (very simple & not correct) Expand method:
Our real life example:
Predicate1(X) = Get all users where X
Predicate2(X) = Get all users and their deputies from (Get all users where X)
so we are calling Predicate2.Invoke(Predicate1.Invoke(X)) and this fails.
The text was updated successfully, but these errors were encountered: