以下是导致它的代码:
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,泄漏谓词。 at System.Data.Query.PlanCompiler.PlanCompiler.Assert(布尔条件,字符串消息) 在System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTreeForCrossJoins(AugmentedJoinNode joinNode) 在System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedJoinNode joinNode,Dictionary
2& predicates) at System.Data.Query.PlanCompiler.JoinGraph.RebuildNodeTree(AugmentedNode augmentedNode, Dictionary
2& predicates) 在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, Dictionary
2& processedNodes) 在System.Data.Query.PlanCompiler.JoinElimination.ProcessJoinGraph(Node joinNode) 在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](BasicOpVisitorOfT
1 v,Node n) 在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.访问(FilterOp op,Node n) at System.Data.Query.InternalTrees.FilterOp.Accept [TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT
1.VisitNode(Node n) 在System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitChildren(Node n) 在System.Data.Query.PlanCompiler.JoinElimination.VisitDefaultForAllNodes(Node n) 在System.Data.Query.PlanCompiler.JoinElimination.VisitDefault(Node n) 在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](BasicOpVisitorOfT
1 v,Node n) 在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.BasicOpVisitorOfT
1.访问(PhysicalProjectOp op,Node n) at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept [TResultType](BasicOpVisitorOfT1 v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitorOfT
1.VisitNode(Node n) 在System.Data.Query.PlanCompiler.JoinElimination.Process() 在System.Data.Query.PlanCompiler.PlanCompiler.Compile(List1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set
1& 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 context,DbQueryCommandTree tree,Type elementType,MergeOption mergeOption,Span span,ReadOnlyCollection1 compiledQueryParameters, AliasGenerator aliasGenerator) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable
1 forMergeOption) 在System.Data.Objects.ObjectQuery1.GetResults(Nullable
1 forMergeOption) 在System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 source) 在MyProject.UIEntities.UserSession.SaveReadingSession(UserSession uiEntity,MyEntities db)中的c:\ src \ MyProject \ MyBL \ UIEntities \ UserSession.cs:第130行
那么,我打破了什么想法?
答案 0 :(得分:1)
...SelectMany(x2 => x.GrandchildThings)...
当然,那应该是x2.GrandchildThings
。问题解决了。