当尝试在已经嵌套的.Include()
上急切地使用ICollection
多对多ICollection
属性时,我收到了EntityCommandCompilationException
和innerException
:{ {1}}
System.NotSupportedException: APPLY joins are not supported.
这是失败的基本代码。有关完整的代码以及如何实现模型,请参见下文。
相反,仅包含两个// Bare minimum model definitions - see below for a full implementation
public class Mode
{
[Key] public int Id { get; set; }
}
public class Type
{
[Key] public int Id { get; set; }
}
public class Preset
{
[Key] public string PresetId { get; set; }
/* Note: Both Types and Modes are Many-To-Many Entity Relationship configured
* using Join Table/Fluent API */
public ICollection<Type> Types { get; set; } = new List<Type>();
public ICollection<Mode> Modes { get; set; } = new List<Mode>();
}
public class Plugin
{
[Key] public int Id { get; set; }
public ICollection<Preset> Presets { get; set; } = new List<Preset>();
}
public void test ()
{
context.Plugins
.Include("Presets.Modes")
.Include("Presets.Types")
.Load();
}
// EntityCommandCompilationException An error occurred while preparing the command definition. See the inner exception for details.
// innerException System.NotSupportedException: APPLY joins are not supported
导航属性中的一个可以正常工作:
ICollection
另外,在同一级别上包含多个context.Plugins
.Include("Presets.Modes")
.Load();
可以正常工作:
ICollection
context.Presets
.Include("Modes")
.Include("Types")
.Load();
的类似StackOverflow question,并且(易于使用的)SQLite Bugtracker和邮件列表似乎都没有提到这个特定问题.Include()