3

Wow, I never thought I would cause an error that yields zero hits on Google.

Here's the code that caused it:

var otherSessions = 
db.ChildThing.Where(x => x.ID == thingOneID)
  .SelectMany(x => x.ParentThing.ChildThings.SelectMany(x2 => x.GrandchildThings))
  .Where(x=> x.Field1 == null)
  .ToList();

And here's the exception:

System.Data.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details. ---> System.InvalidOperationException: Internal .NET Framework Data Provider error 1004, 0, Leaking predicates. at System.Data.Query.PlanCompiler.PlanCompiler.Assert(Boolean condition, String message) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTreeForCrossJoins(AugmentedJoinNode joinNode) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedJoinNode joinNode, Dictionary2& predicates) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedNode augmentedNode, Dictionary2& predicates) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedJoinNode joinNode, Dictionary2& predicates) at System.Data.Query.PlanCompiler.JoinGraph.BuildNodeTree() at System.Data.Query.PlanCompiler.JoinGraph.DoJoinElimination(VarMap& varMap, Dictionary2& processedNodes) at System.Data.Query.PlanCompiler.JoinElimination.ProcessJoinGraph(Node joinNode) at System.Data.Query.PlanCompiler.JoinElimination.VisitJoinOp(JoinBaseOp op, Node joinNode) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.Visit(InnerJoinOp op, Node n) at System.Data.Query.InternalTrees.InnerJoinOp.Accept[TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitChildren(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefaultForAllNodes(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitRelOpDefault(RelOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.Visit(FilterOp op, Node n) at System.Data.Query.InternalTrees.FilterOp.Accept[TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitChildren(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefaultForAllNodes(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitRelOpDefault(RelOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept[TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitChildren(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefaultForAllNodes(Node n) at System.Data.Query.PlanCompiler.JoinElimination.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitPhysicalOpDefault(PhysicalOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.Visit(PhysicalProjectOp op, Node n) at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept[TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.PlanCompiler.JoinElimination.Process() at System.Data.Query.PlanCompiler.PlanCompiler.Compile(List1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set1& entitySets) at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) --- End of inner exception stack trace --- at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) at System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) at System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree) at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection1 compiledQueryParameters, AliasGenerator aliasGenerator) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) at System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at MyProject.UIEntities.UserSession.SaveReadingSession(UserSession uiEntity, MyEntities db) in c:\src\MyProject\MyBL\UIEntities\UserSession.cs:line 130

So, any ideas what I broke?

1
  • 1
    I rather like the error message 'Leaking Predicates' - well done for finding it! Commented Jul 2, 2013 at 15:07

1 Answer 1

1

Ha, I discovered the answer while I was posting the question! The problem is in that lambda ...SelectMany(x2 => x.GrandchildThings)...

Of course, that should be x2.GrandchildThings. Problem solved.

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

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.