开发者

Entity Framework: Eager Loading Navigation Properties of Inherited Entities

开发者 https://www.devze.com 2023-04-01 02:01 出处:网络
I am trying to eager load my entire graph and it looks like the following: public class WorkoutProgram

I am trying to eager load my entire graph and it looks like the following:

public class WorkoutProgram
{
    public Schedule Schedule { get; set; }开发者_如何学C
}

public class Schedule
{
    public ICollection<DayBase> Days { get; set; }
}

public abstract class DayBase
{
}

public class TrainingDay : DayBase
{
    public ICollection<Exercise> Exercises { get; set; }
}

context.WorkoutPrograms.Include("Schedule.Days.Exercises");

Obviously, not all Schedule.Days are TrainingDays, so I get a runtime error because of the path including Exercises.

Am I missing a configuration here, or do I need to resort to lazy loading (which I hope not).

Thanks


Looks like many developers are having pain of this issue, including me.

Please cast your vote!!!

0

精彩评论

暂无评论...
验证码 换一张
取 消