gpt4 book ai didi

entity-framework - EF Core Second level ThenInclude misworks

转载 作者:行者123 更新时间:2023-12-03 12:08:33 26 4
gpt4 key购买 nike

假设首先拥有这些模型:
Method有一个 OriginalCodeOriginalCode有很多MutantMutant有很多ParseSubTree

现在在 Method 上查询时我想要另一个被加载。所以我有以下几点:

Method targetMethod = dBContext.Methods
.Include(me => me.OriginalCode)
.ThenInclude(oc => oc.Mutants)
.FirstOrDefault(me => me.Id == id);

下一步是额外包含 ParseSubTree .但问题是我无法访问它。见下图:

mu is a list except object reference

问题是“mu 是一个列表而不是一个对象引用”!

我的错在哪里!

TG。

最佳答案

这是 ThenInclude 的已知 Intellisense 问题集合类型导航属性的重载,由 Completion missing members of lambda parameter in fault tolerance case #8237 跟踪Roslyn GitHub 问题。

在它得到修复之前,只需键入属性的名称,它就会成功编译并按预期工作。

.ThenInclude(mu => mu.ParseSubTrees) 

更新:现在它甚至在 Including multiple levels 中特别提到EF Core 文档的部分:

Note

Current versions of Visual Studio offer incorrect code completion options and can cause correct expressions to be flagged with syntax errors when using the ThenInclude method after a collection navigation property. This is a symptom of an IntelliSense bug tracked at https://github.com/dotnet/roslyn/issues/8237. It is safe to ignore these spurious syntax errors as long as the code is correct and can be compiled successfully.

关于entity-framework - EF Core Second level ThenInclude misworks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45658411/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com