简体   繁体   English

EF 4.3.1中子收集的热切加载失败

[英]Eager loading failing for Child Collection in EF 4.3.1

I have the following classes: 我有以下课程:

public class Configuration
{
    public long Id {get;set;}
    public string Name {get;set;}
    public Expression Criteria {get;set;}
}

public class Expression
{
    public long Id {get;set;}
    public string Value {get;set;}
    public ICollection<Parameter> Parameters {get;set;}
}

public class Parameter
{
    public long Id {get;set;}
    public MyType Type {get;set;}
}

public class MyType
{
    public long Id {get;set;}
    public string Name {get;set;}
}

I am trying to eagerly load the entire configuration object using: 我试图使用以下方法加载整个配置对象:

dbContext.Configurations.Select(i => i.Criteria).Include(i => i.Parameters.Select(j => j.Type)).ToList()

I am however getting null for the Parameters property and it is not getting fetched. 但是,我为Parameters属性获取了null,并且没有获取它。

What am I doing wrong. 我究竟做错了什么。

尝试这个:

dbContext.Configurations.Select(i => i.Criteria).Include("Parameters").Include("Parameters.Type").ToList()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM