【问题标题】:Eager loading failing for Child Collection in EF 4.3.1EF 4.3.1 中的子集合急切加载失败
【发布时间】:2012-06-22 06:30:21
【问题描述】:

我有以下课程:

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;}
}

我正在尝试使用以下方法急切地加载整个配置对象:

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

但是,我的 Parameters 属性为 null,并且没有被获取。

我做错了什么。

【问题讨论】:

    标签: entity-framework entity-framework-4 entity-framework-4.1 eager-loading


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      • 2010-11-24
      • 2013-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多