I am struggling with the problem from Entity Framework - Include Multiple Levels of Properties
Given these classes:
class Survey {
public virtual List<QuestionBase> Questions {get;set;}
...
}
class QuestionType1 : QuestionBase {
public List<Answers> Answers {get;set;}
...
}
class QuestionType2 : QuestionBase {
...
}
Iam trying to get an instance for deep cloning and cannot get the Answers included using:
Survey originalEntity = DBSet
.Include(s => s.Questions)
.Include(s => s.Questions.OfType<QuestionType1>().Select(q => q.Answers))
.AsNoTracking()
.Single( e => e.Id == sourceId );
using this i get the error 'The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties. Parameter name: path'