I have structure like this
class Lesson {
List<Sign> signs { get; set; }
}
class Sign {
List<Media> media { get; set;}
}
class Media {
}
Now I’m using this LINQ to get all lessons
var items = (from lesson in this.db.Lesson.Include("Sign")
where lesson.module_id == param
select lesson);
It works fine but signs list has ampty media list. I mean that attribute media in each object Sign equals null. What do I need to do to include media objects for each Sign ? Whole data is kept in database
You’d use
db.Lesson.Include("signs.media").The argument to
ObjectQuery<T>.Includeis a property path, not just a single root property. Note that with “signs.media” you wouldn’t need to also include “signs” separately:(You should adjust your property names to conform to .NET framework conventions, by the way, so you’d end up with “Signs.Media”.)