3

哇,我从没想过我会导致在 Google 上产生零点击的错误。

这是导致它的代码:

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

这是一个例外:

System.Data.EntityCommandCompilationException:准备命令定义时出错。有关详细信息,请参阅内部异常。---> System.InvalidOperationException:内部 .NET Framework 数据提供程序错误 1004、0、泄漏谓词。在 System.Data.Query.PlanCompiler.PlanCompiler.Assert(布尔条件,字符串消息) 在 System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTreeForCrossJoins(AugmentedJoinNode joinNode) 在 System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedJoinNode joinNode , 字典2& predicates) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedNode augmentedNode, Dictionary2 和谓词) 在 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& 处理节点)在 System.Data.Query.PlanCompiler.JoinElimination.VisitJoinOp(JoinBaseOp op,节点 joinNode)的 System.Data.Query.PlanCompiler.JoinElimination.ProcessJoinGraph(节点 joinNode)在 System.Data.Query.InternalTrees.BasicOpVisitorOfT 1.Visit(InnerJoinOp op, Node n) at System.Data.Query.InternalTrees.InnerJoinOp.Accept[TResultType](BasicOpVisitorOfT1 v , 节点 n) 在 System.Data.Query.InternalTrees.BasicOpVisitorOfT 1.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, 节点 n) 在 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.BasicOpVisitorOfT 1.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept[TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT 1.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](BasicOpVisitorOfT 1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT1.VisitNode(Node n) at System.Data.Query.PlanCompiler.JoinElimination.Process() 在 System .Data.Query.PlanCompiler.PlanCompiler.Compile(列表1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set1& entitySets) 在 System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) --- 内部异常堆栈跟踪结束 --- 在 System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree ) 在 System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree) 在 System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree) 在 System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree) 在System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext 上下文,DbQueryCommandTree 树,类型 elementType,MergeOption mergeOption, Span span, ReadOnlyCollection1 compiledQueryParameters, AliasGenerator aliasGenerator) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable1 forMergeOption) 在 System.Data.Objects.ObjectQuery 1.GetResults(Nullable1 forMergeOption) 在 System.Data.Objects.ObjectQuery 1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable 1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) 在 MyProject.UIEntities.UserSession.SaveReadingSession(UserSession uiEntity, MyEntities db) 在 c:\ src\MyProject\MyBL\UIEntities\UserSession.cs:第 130 行

那么,我打破了什么想法?

4

1 回答 1

1

哈,我在发布问题时发现了答案!问题在于那个 lambda...SelectMany(x2 => x.GrandchildThings)...

当然,应该是这样x2.GrandchildThings。问题解决了。

于 2013-07-02T13:24:13.317 回答