EF Core Second level ThenInclude missworks [英] EF Core Second level ThenInclude missworks
问题描述
假设首先使用这些模型:
Assume having these models first:
方法
有一个 OriginalCode
OriginalCode
有多个 Mutant
s
Mutant
有很多 ParseSubTree
s
Method
that has one OriginalCode
OriginalCode
that has many Mutant
s
Mutant
that has many ParseSubTree
s
现在查询方法
我希望另一个被加载。所以我有以下内容:
Now when querying on Method
I want the other being loaded. So I have the following:
Method targetMethod = dBContext.Methods
.Include(me => me.OriginalCode)
.ThenInclude(oc => oc.Mutants)
.FirstOrDefault(me => me.Id == id);
,下一步是另外包含 ParseSubTree
。但问题是我无法访问它。请参阅下图:
and the next step is to include additionally the ParseSubTree
. But the thing is that I can't access it. See the following Image:
问题是mu是一个列表而不是一个对象引用!
the problem is "mu is a list instead of being an object reference"!
我的错误在哪里!
TG。
推荐答案
这是一个已知的Intellisense问题,其中包含 ThenInclude
重载对于集合类型导航属性,由在容错案例#8237中完成缺少lambda参数的成员跟踪 Roslyn GitHub问题。
This is a known Intellisense issue with the ThenInclude
overload for collection type navigation properties, tracked by the Completion missing members of lambda parameter in fault tolerance case #8237 Roslyn GitHub issue.
在修复之前,只需输入属性的名称,它就会成功编译并按预期工作。
Until it gets fixed, simply type the name of the property and it will compile successfully and work as expected.
.ThenInclude(mu => mu.ParseSubTrees)
这篇关于EF Core Second level ThenInclude missworks的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!