I'm trying to make reusable includes and it currently works when I have specific concrete root entity. But let's say I have structure like this:
public class A
{
public B NavigationB { get; set; }
}
public class B
{
public C NavigationC { get; set; }
}
public class C
{
}
And my include extensions
public static class IncludeExtensions
{
public static IQueryable<B> MyIncludesB(this IQueryable<B> query)
{
return query.Include(q => q.NavigationC);
}
public static IQueryable<A> MyIncludesA(this IQueryable<A> query)
{
return query.Include(q => q.NavigationB)
.MyIncludesB(); // how can I implement this
}
}
Basically everything is okay if I have single root e.g. A
, but what if I want to do fetch using root B
? The idea is to then include everything required for B
, but when using A
as root then include everything for A
, and when including B
, reuse MyIncludesB
.
I'm not sure if this is possible because include is returning IIncludableQueryable<A, B>
, but if anyone has any suggestions, feel free to help!