In my repository, I get data from my TransportedMaterial table. I also ‘include’ TransportedMaterialPacking to retrieve all related data in this linked table. In this last table I also would like to retrieve the related MaterialPacking data. I don’t know how?

On the picture above we see that the MaterialPacking is null (it has not been filled).
Here are the models:
public class TransportedMaterialPacking
{
public int TransportedMaterialPackingID { get; set; }
public MaterialPacking MaterialPacking { get; set; }
public double Quantity { get; set; }
public double? Width { get; set; }
public double? Height { get; set; }
public double? Length { get; set; }
}
public class MaterialPacking
{
public int MaterialPackingID { get; set; }
public string DescriptionFr { get; set; }
public string DescriptionNl { get; set; }
}
The relations are like this:
TransportedMaterial >> TransportedMaterialPacking >> MaterialPacking
public static class ORMExtensions
{
public static IQueryable<T> MyInclude<T, C>(this IQueryable<T> source, Expression<Func<T, C>> function)
where C : class
where T : class
{
return source.Include(function);
}
I use Entity framework.
Thanks.
You can ‘cascade’ include by doing something like
foo.Include("NavigationProperty.SubNavigationProperty")in your query.Edit Using property notation to include navigation subproperties is possible, see this for example.