29

The Entity Framework does not support the Expression.Invoke operator. You receive the following exception when trying to use it:

"The LINQ expression node type 'Invoke' is not supported in LINQ to Entities.

Has anyone got a workaround for this missing functionality? I would like to use the PredicateBuilder detailed here in an Entity Framework context.

Edit 1 @marxidad - I like your suggestion, however it does baffle me somewhat. Can you give some further advice on your proposed solution?

Edit 2 @marxidad - Thanks for the clarification.

2
  • Yeah, looks like Entity Framework doesn't support this, nor could i jerry-rig a way to get it to evaluate in a way that would work. Commented Aug 15, 2008 at 16:17
  • have a look at the CLR Method to Canonical Function Mapping page on MSDN. Commented Aug 19, 2008 at 2:48

2 Answers 2

31

PredicateBuilder and LINQKit now support Entity Framework.

Sorry, guys, for not doing this earlier!

Sign up to request clarification or add additional context in comments.

2 Comments

Yep- it works now. Just add AsExpandable() before your .Where<>() and your good to go.
When I add the AsExpandable(), I'm receiving "Unable to cast object of type 'System.Linq.Expressions.MemberExpression' to type 'System.Linq.Expressions.LambdaExpression'." in the VisitInvocation at the line LambdaExpression lambda = (LambdaExpression)target;
0

The Entity framework converts LINQ expressions into Entity Command trees and within that only its canonical functions are supported. You'd have to use the command trees with canonical functions to do something like PredicateBuilder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.